Upload with Ajax


I want to upload an image with ajax, I want to transmit only the image field, ie when you select an image it will be uploaded directly, and other form fields will be transmitted with a submit button.

There exists a solution with Yii?

There is no solution at all.

Javascript is not allowed to read file in the filesystem, tharefore there are no hope of send a file with ajax or any other javascript code.

Gmail, for instances, uses flash, as it is allowed to read file in the filesystem, but with javascript is impossible.

I too run into this problem just yesterday, and wherever is explained this detail: javascript cannot upload file.

There are some extension like this that integrate some applet for image upload, but I never tried and I cannot say you if they work properly or not.

I can only point it you.

Let us know if you find something interesting.

what do you think about this extension uploadif or this sfancyupload ?

If your users browser supports some HTML5 stuff you can upload a file with ajax,

Just recently I found a nice jQuery upload plugin…


You can even drag & drop a file from your folder to the browser… very nice :D

I’m currently testing uploadify, when I replace the contents of the variable ‘script’:’/uploadify/uploadify.php’ with something like this ‘script’:‘index.php?r=company/image’, the script will not work and it generates an error http.

I need to update a BLOB in the database!!!

Waouh! That exctly what I need for my new website.

But how to use this with yii?


Beware of the security implications when using flash based uploaders.

This really looks very promising, thanks mdomba. But there are some drawbacks:

[color=#222222][font=Verdana, Arial, sans-serif][size=2]


[color=#222222][font=Verdana, Arial, sans-serif][size=2]


[color=#222222][font=Verdana, Arial, sans-serif][size=2][color=#000000][font=arial, verdana, tahoma, sans-serif][size=3]BTW, did i mention that i hate IE…? [/size][/font][/color][/size][/font][/color]

Here is one more library doing the ajax file upload: http://en.dklab.ru/lib/JsHttpRequest/