How to open a file in external editor programmatically in eclipse plugin development?

WordPress Plugin Development: How can I access $_FILES with Settings API?

  • I'm trying to achieve the same thing to the below script with Settings  API. It lets the user upload a file and if the form is sent, it just  displays the $_FILES array containing the information of the submitted  file. <?php if ( isset( $_POST['submit'] ) ) echo '<pre>' . print_r( $_FILES, true ) . '</pre>'; ?> <html> <body> <form action="" method="post" enctype="multipart/form-data"> <input type="file" name="file" /><br /> <input type="submit" name="submit" value="Upload"> </form> </body> </html> Now Settings API does not seem to allow us to access the $_FILES array. I'm wondering if there is a way to do it. <?php /* Plugin Name: Test Settings API with File Input Type */ add_action('admin_init', 'func_settings_api_init' ); function func_settings_api_init(){ register_setting( 'group_settings_test', 'key_test_file_input', 'func_validation' ); add_settings_section( 'section_test_file', 'Section Demo', 'func_section_description', 'page_test_settings_api_file' ); add_settings_field( 'field_file', 'Field File', 'func_field_file', 'page_test_settings_api_file', 'section_test_file' ); } function func_field_file() { $options = (array) get_option('key_test_file_input'); ?> <input type="file" name="key_test_file_input[page_test_settings_api_file][field_file]" /> <?php } add_action('admin_menu', 'func_test_settings_api_file'); function func_test_settings_api_file() { add_options_page( 'Test Settings API with File Input Type', 'Test Settings API with File Input Type', 'manage_options', 'page_test_settings_api_file', 'func_test_field_type_file_admin_page'); } function func_test_field_type_file_admin_page() { ?> <div class="wrap"> <?php screen_icon(); ?> <h2>Test Settings API File</h2> <form action="options.php" method="post"> <?php settings_fields('group_settings_test'); do_settings_sections('page_test_settings_api_file'); submit_button(); ?> </form> </div> <?php $key = 'key_test_file_input'; echo 'Option Key: ' . $key . '<pre>' . print_r( get_option( $key ), true ) . '</pre>'; echo '$_FILES<pre>' . print_r( $_FILES, true ) . '</pre>'; } function func_section_description() { echo '<p>' . __FUNCTION__ . '</p>'; } function func_validation( $input ) { add_settings_error( $_POST['page'], 'abcde', '$_POST<pre>' . print_r( $_POST, true ) . '</pre>' . '$_FILES<pre>' . print_r( $_FILES, true ) . '</pre>' . '$input<pre>' . print_r( $input, true ) . '</pre>' ); return $input; }

  • Answer:

    Never mind, enctype="multipart/form-data" was missing in the form tag.

Anonymous at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.