PDA

View Full Version : Uploader


NeoPuma
06-19-2008, 06:20 PM
Hey Guys
I've got a PHP script which is designed to add an item to a database with an photograph that's uploaded and saved with a matching ID. Here's the problem:
Firstly, how can I make an uploader using AJAX,
Secondly, How can I return the name of the file uploaded into a form field in the document so it's posted with the rest of the data.

Cheers in advance
Neo

NancyJ
06-20-2008, 04:54 PM
The simple answer is, you can't.

You can't upload files via ajax - you can however cheat it using an iframe. Basically you create an invisible iframe and make it the target of your upload form. As for returning the name, I guess you could try to retrieve it from the iframe once the upload is done.

hotwheelharry
06-22-2008, 08:21 PM
NeoPuma,
Do you mean something like this?

http://www.componentart.com/webui/demos/demos_control-specific/upload/features/core_features/WebForm1.aspx

It is Ajax updated during the upload, and is in ASP.NET though.


EDIT: Better link found.

This one is in PHP and uses an embedded iframe.
http://www.ajaxf1.com/tutorial/ajax-file-upload-tutorial.html