Ajaxified File Uploader Using IFrame
Today, while writing a code for AJAX file uploader, I was trying to do with [wiki]SALAJAX[/wiki]. 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 [wiki]IFrame[/wiki], 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 [wiki]AJAX[/wiki], 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.
[sourcecode=”html”]
[/sourcecode]
You can see on #1 the action of the form is iframeinc.php. The code for this page is given below. There are some other things you should remember. Like the target for the form is set iframe, whose display is set none so that it is not seen. And this iframe is the of the iframe created on #6, whose source is the iframeinc.php. Now here’s its code.
[sourcecode=”php”]
[/sourcecode]
Remember to set $newname value before running this. At first run you may see this as a regular post script, but try to reload with f5 or reload button of your browser, you will not be asked to retry or resend the post header. So, there are own ways of catching your nose.
[Download Source]