Note that there are some explanatory texts on larger screens.

plurals
  1. POAjaxUpload $_FILES array is empty
    text
    copied!<p>I'm trying to use wordpress' built-in ajax to process an upload using the AjaxUpload script. The script was updated in august, and now i can't get it to work any more. </p> <p><a href="http://valums.com/ajax-upload/" rel="nofollow noreferrer">http://valums.com/ajax-upload/</a></p> <p>here's my jquery... this seems to be in place as i get input is transformed into an upload button and on selection of the image it begins to attempt to upload automatically.</p> <pre><code>jQuery.noConflict(); jQuery(document).ready(function($) { /* * AJAX UPLOAD * http://valums.com/ajax-upload/ */ var uploader = new qq.FileUploader({ // pass the dom node (ex. $(selector)[0] for jQuery users) element: document.getElementById('file-uploader'), // path to server-side upload script action: ajaxurl, params: { type: "POST", action: 'save_function', key: 'logo', }, onComplete: function(id, fileName, responseJSON){ console.debug("Here is the response: %o", responseJSON); } }); }); //end document.ready functions </code></pre> <p>my action is set to ajaxurl which is the constant for /wp-admin/admin-ajax.php, i passed an action in the params so that admin-ajax would know what function i wanted to run to process things. and my callback function</p> <pre><code>function childtheme_data_save_callback() { global $my_shortname; $id = $_POST['key']; // option name $upload = wp_handle_upload($_FILES['qqfile']['tmp_name'], array('test_form' =&gt; false)); if(!empty($upload['error'])) { //there IS an error message die($upload['error']); } else { // there is NOT an error $upload_image = $my_data; //preserve current data $upload_image[$id] = $upload['url']; update_option($my_shortname .'_options', $upload_image ) ; die($upload['url']); //response sends url back to jquery } } add_action('wp_ajax_save_function', 'childtheme_data_save_callback'); </code></pre> <p>which is getting called and my error message is showing in my firebug console. here is the error</p> <p>File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.</p> <p>dabbling w/ changing the error messasge to $_FILES it always comes back an empty array, even though in console it says the POST is filled w/ stuff that looks like </p> <pre><code>ÿØÿà�JFIF��_�_��ÿÛ�C� $.' ",#(7),01444'9=82&lt;.342ÿÛ�C 2!!22222222222222222222222222222222222222222222222222ÿÀ�° </code></pre> <p>and more. though now i see that console also says the Response Headers have a content type of: Content-Type text/html; charset=UTF-8</p> <p>and the request headers accept: Accept text/html,application/xhtml+xml,application/xml;q=0.9,<em>/</em>;q=0.8</p> <p>is the problem then in not sending the POST in "multipart/form-data" encoding? if so how do i switch to that since i'm using this plugin and not a form tag? if not, well i have been stumped for a while now.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload