"Empty file upload result" Despite Upload Working and Returning Result

3,427 views
Skip to first unread message

Dave Rogers

unread,
Jan 5, 2013, 10:19:25 PM1/5/13
to jquery-f...@googlegroups.com
I'm using PHP (YES GD is installed, YES upload is on, YES upload file size is 20mb and I'm NOT uploading anything bigger than half a megabyte at this point) - specifically Codeigniter using this user-created script except for the view. I'm not using anything with thumbnails so I just set the thumbnail_url key to the image itself. The upload is successful (image ends up in the correct folder) and it returns the following JSON:

[{"name":"lolzwat1.JPG","size":2017.94,"type":"image\/jpeg","url":"http:\/\/www.krashdrive.dev\/uploads\/lolzwat1.JPG","thumbnail_url":"http:\/\/www.krashdrive.dev\/uploads\/lolzwat1.JPG","delete_url":"http:\/\/www.krashdrive.dev\/upload\/deleteImage\/lolzwat1.JPG","delete_type":"DELETE"}]

What is jQuery-File-Upload expecting in return that isn't listed here? main.js is set to dataType json, so it should be looking for this result.

Deyan Stoinov

unread,
Jan 30, 2013, 9:42:26 AM1/30/13
to jquery-f...@googlegroups.com
Try to return {"files":[{"name":"lolzwat1.JPG","size":2017.94,"type":"image\/jpeg","url":"http:\/\/www.krashdrive.dev\/uploads\/lolzwat1.JPG","thumbnail_url":"http:\/\/www.krashdrive.dev\/uploads\/lolzwat1.JPG","delete_url":"http:\/\/www.krashdrive.dev\/upload\/deleteImage\/lolzwat1.JPG","delete_type":"DELETE"}]}

That takes me 1 day to figure it out and I don't know why this "little" change is not documented or I missed something :/

Dave Rogers

unread,
Feb 8, 2013, 7:16:33 AM2/8/13
to jquery-f...@googlegroups.com
Thanks! That worked :)

sebastien...@gmail.com

unread,
Feb 8, 2013, 8:02:06 AM2/8/13
to jquery-f...@googlegroups.com
Hello,
In which part of the code may I apply this modification ?

Deyan Stoinov

unread,
Feb 8, 2013, 8:06:42 AM2/8/13
to jquery-f...@googlegroups.com
Your JSON result after uploading the file/s must be 
{
    files:[ {file1}, {file2} .....  ]

sebastien...@gmail.com

unread,
Feb 8, 2013, 8:45:53 AM2/8/13
to jquery-f...@googlegroups.com
Thanks a lot !!! It finally works !!
You saved my day ;-)

Andrei Onel

unread,
Feb 11, 2013, 1:01:10 PM2/11/13
to jquery-f...@googlegroups.com
Sorry to ask this, but how do you that ?

Deyan Stoinov

unread,
Feb 11, 2013, 1:56:37 PM2/11/13
to jquery-f...@googlegroups.com
What do you mean ?

Andrei Onel

unread,
Feb 11, 2013, 2:04:24 PM2/11/13
to jquery-f...@googlegroups.com
Thanks for the quick response.

So I'm trying the codeigniter example from github page
https://github.com/blueimp/jQuery-File-Upload/wiki/jQuery-File-Upload-6.5-with-CodeIgniter-2.1

And I'm getting this error: Empty file upload result

So I thought that Dave's problem was similar to mine.
My controller sends back this response:

            $info
->name = $name;
            $info
->size = $data['file_size'];
            $info
->type = $data['file_type'];
            $info
->url = $this->getPath_img_upload_folder() . $name;
            $info
->delete_url = $this->getDelete_img_url() . $name;
            $info
->delete_type = 'DELETE';

            echo json_encode
(array($info));

And I can't understand why in the world is giving me that error. I've done exactly as it is written on the site.
Why doesn't it recognizes the json response ?

On Monday, February 11, 2013 8:56:37 PM UTC+2, Deyan Stoinov wrote:
What do you mean ?

Deyan Stoinov

unread,
Feb 11, 2013, 2:11:06 PM2/11/13
to jquery-f...@googlegroups.com
I don't know how to code it but the wrap entire array in other object with single property 'files' => { files: arrayWithFiles }

Andrei Onel

unread,
Feb 11, 2013, 3:55:23 PM2/11/13
to jquery-f...@googlegroups.com
Thanks again for the info.

So if anyone is having problems with json response of the Codeigniter installation from github (getting the " Empty file upload result" error), try to replace


echo json_encode
(array($info));



With this

            echo json_encode(array('files' => array($info) ));

It worked in my case.

Chetan Pedgaonkar

unread,
Dec 10, 2013, 11:13:16 AM12/10/13
to jquery-f...@googlegroups.com
Thanks this works for me!
Reply all
Reply to author
Forward
0 new messages