I am building a plugin which has a file upload field in it's settings page. The files should not be image files but should be .doc, .txt etc. Struggling with the code for it. Any help would be greatly appreciated !
Edit 1: Here is the code -
$options = get_option('nn_sub_general_options'); if(!isset($options['nn_file_uploader'])) $options['nn_file_uploader'] = ''; require_once( ABSPATH . 'wp-admin/includes/file.php' ); echo "<form method='post' action='options.php' enctype='multipart/form-data'> <input type='file' name='nn_sub_general_options[nn_file_uploader]' id='nn_sub_general_options[nn_file_uploader]' /></form>"; $uploadedfile = $_FILES['nn_sub_general_options[nn_file_uploader]']; $upload_overrides = array( 'test_form' => false ); $movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
There seems to be some problem with the 3rd last line of the code as it gives me an Undefined index error there