I am trying to do an upload via ajax and really dont want to use the regular wordpress media uploader. It is too much stuff and all i want to do is upload single image.

I have everything working the ajax is sending the uploaded file via this Jquery plugin LINK I got it all set up and isn't the problem.

Here is my function that is being called to upload however i always am returned this error message.

    if ( !empty($_FILES['files']) ) {
        $daFile = $_FILES['files'];

        $upload = wp_handle_upload($daFile , array('test_form' => FALSE));


and error message that is returned from $upload

   array(1) { ["error"]=> array(1) { [0]=> int(0) }}

Note I am using WPMU. I have checked online a ton about this but cant see why I am getting this blank error array...

This is for a front end uploader for users. Does wp_handle_upload care about user privileges ie if logged in or not admin? if so what should I do to just upload this damn thing to the server? I just need the url link by the end of this function.


  • 1
    the plugin you linked to is set up to accept multiple images in a single field via the multiple attribute, are you sure $_FILES['files'] isn't an array?
    – Milo
    Aug 27, 2013 at 21:37
  • your right i left it as a multiple file upload so i can also pass additional formData to it for this to work. hmm i think files is an array... I thought that it needed to be... that's probably the problem what should I pass in to it instead? here is the response of what var_dump returned from var_dump($daFile); array(5) { ["name"]=> array(1) { [0]=> string(9) "Koala.jpg" } ["type"]=> array(1) { [0]=> string(10) "image/jpeg" } ["tmp_name"]=> array(1) { [0]=> string(14) "/tmp/php4UnYgj" } ["error"]=> array(1) { [0]=> int(0) } ["size"]=> array(1) { [0]=> int(780831) }}
    – Aaron
    Aug 27, 2013 at 21:47
  • ahh i think i may need to pass $_FILES['files'][name] let me try that.. edit: no that isn't right either.
    – Aaron
    Aug 27, 2013 at 21:48
  • in your var dump, note how each of the array keys contain arrays- name is an array with length of 1, where that single array element contains the name in the form of a string. if it weren't a multiple file upload, name would just be a string. have a look in the php docs at example #3
    – Milo
    Aug 27, 2013 at 22:02

1 Answer 1


Okay so Milo was on track to what the answer was. and I needed to brush up on muliple file uploads... anyway the solution for me to at least get it to upload... was this

    $daFile = $_FILES['files'];
    foreach ($_FILES['files'] as $key => $value) {

        $daFile[$key] = $value[0]; 


    $upload = wp_handle_upload($daFile , array('test_form' => FALSE));

this worked for me and retuned the uploaded file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.