File upload and Ajax

Hi people, I’m writing here cause I’ve a problem with a file upload form using ajax.

File upload can’t be executed with ajax and i solved it using <iframe></iframe>

so my form look like this:

<form name="myform" id="myform" method="post" action="myController/actionFileUpload" enctype="multipart/form-data" target="upload_target">

File: <input name="myfile" type="file" />

<input type="submit" name="submitBtn" value="Upload" />

<iframe id="upload_target" name="upload_target" style="width:0;height:0;border:0px solid #fff;"></iframe>

When i submit the file, yii doesn’t call myController/actionFileUpload but it call myController/actionIndex

How can it be solved?

Ok, I solved with this code:

<form name="myform" id="myform" method="post" action="" method="post" enctype="multipart/form-data" target="upload_target">

<input type="hidden" name="r" value="myController/actionFileUpload" />


Marco, you can upload a file using ajax!

Try using jquery.form.js next time :