22
Jul
Ajaxified File Uploader Using IFrame
Filed Under (Ajax, PHP) by Subesh Pokhrel on 22-07-2008
Tagged Under : Ajax, fileupload, PHP
Today, while writing a code for AJAX file uploader, I was trying to do with SALAJAX. But, with SALAJAX I could not manage to send the headers for $_FILES. So I thought of an alternative. And the alternative was to load the action page of the form on IFrame, whose display would be hidden and the work for uploading the file will be done on the background without refreshing the page. Yeha.. Its not AJAX, but it gives a user the feel of asynchronous working on the page. So, my code is Asynchronous Feel Without Javascript and XML (AFWJAX). What do think about this?
So, Here’s the code.The code below is for the form.
<form action="iframeinc.php" method="post" enctype="multipart/form-data" id="uploadform" target="iframe" name="uploadform"> File: <input name="pic" type="file" id="pic" style="margin-right:50px;" /> <br /> <input type="submit" name="Submit" value="Upload" ><br /> <iframe name="iframe" src="iframeinc.php" width="200" height="500" style="display:none;"> </iframe> </form>
![[del.icio.us]](http://subesh.com.np/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://subesh.com.np/wp-content/plugins/bookmarkify/digg.png)
![[Facebook]](http://subesh.com.np/wp-content/plugins/bookmarkify/facebook.png)
![[Google]](http://subesh.com.np/wp-content/plugins/bookmarkify/google.png)
![[MySpace]](http://subesh.com.np/wp-content/plugins/bookmarkify/myspace.png)
![[StumbleUpon]](http://subesh.com.np/wp-content/plugins/bookmarkify/stumbleupon.png)
![[Technorati]](http://subesh.com.np/wp-content/plugins/bookmarkify/technorati.png)
![[Windows Live]](http://subesh.com.np/wp-content/plugins/bookmarkify/windowslive.png)
![[Yahoo!]](http://subesh.com.np/wp-content/plugins/bookmarkify/yahoo.png)

