AJAX File Upload?

I want to upload an image file through AJAX and sending to to new server side script, which actually resizing the image ans shwing resized image. Through normal file upload I can be able to do that but I want to do that with AJAX , so that I can show the resize image on a flow, without sending user to new url or script path.

Please tell me, if anyone knows the script which can help me to upload image files through AJAX, I knw in normal AJAX file upload cannot be possible, it will be using an iframe I think. I am thankful in advance if someone has the solution for this issue.

Who is Participating?
ZvonkoConnect With a Mentor Systems architectCommented:
I am really astonished that it can work because my understanding was that file upload controls cannot be controled by script. And I did not know anoter way to get imiage file content data bytes to send them as information in background. But it seams the data island assingment can do that:
 // create a new node and set binary content
 var fileNode = xmlSOAP.selectSingleNode("//file");
 fileNode.dataType = "bin.base64";
 // open stream object and read source file
 if (adoStream.State != 1 )
  adoStream.Type = 1;  // 1=adTypeBinary
Look here for the complete script:

Michel PlungjanIT ExpertCommented:
Hmm looking at the code there, it uses pretty heavy activeX which has to be accepted by the user
proteam4Author Commented:
Thanks for reply, but I want activeX free script for my PHP, I am using php as a server side scripting. can you help in with php?
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Michel PlungjanIT ExpertCommented:
I would think you need the file form element.
Then you can auto post it to a normal php file upload

proteam4Author Commented:
I need PHP + AJAX
Go through following link in this they use PHP and AJAX to upload an image.

Michel PlungjanIT ExpertCommented:
Second link in the google I posted.
proteam4Author Commented:
thanks for these links, can you tell me, how do I pas varibles in src of an iframe. I want to pass like script.php?var1=value   but this is not happening..
Michel PlungjanIT ExpertCommented:
Not enough info.

If you use
then in script.php you have
$var1 = $_GET["var1"];
Michel PlungjanIT ExpertCommented:
I would say split me {http:#19977112} and Zvonko {http:#19976913}
b0lsc0ttIT ManagerCommented:

Thanks for the comment and recommendation.  I'll change mine.  As I looked at this again (after some sleep :] ) it seems the Asker said he was helped by those links.

    Changed recommendation:  Split - mplungjan {http:#19977112} and Zvonko {http:#19976913}

Let me know if there are any objections.

EE Cleanup Volunteer
Forced accept.

EE Admin
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.