Can I send a temporary filename to be loaded with jquery

I need to submit a form containing personal details and I need to upload an attachment file and I need to do this with AJAX.

How can I upload a file using AJAX, I need to post personal details and also upload a file at the same time using AJAX, how can I do this?

+1


a source to share


2 answers


You cannot upload files using AJAX because you cannot make multipart encoded requests - this is a limitation of the XMLHttpRequest API.



Workarounds for this usually involve using an IFRAME, which is a form object that handles the actual file upload as a separate sub-process into the overall form. The response loaded in the IFRAME is then passed back to the DOM on the parent / calling page with information about the loaded file.
+3


a source


If you add a hidden iframe to the page

<iframe name="iframe1" ... />

      

And changing the target in your form to post to an iframe

<Form traget="iframe1" ...>...</form>

      



You can download and publish the data on the page. You can also use javascript (JQuery) to hook up to iframe events.

To get the upload progress bar, use the php uploadprogress module. It works great! http://pecl.php.net/package/uploadprogress and also http://bluga.net/projects/uploadProgressMeter/

Here is a link I found that might help: http://www.finalwebsites.com/forums/topic/php-ajax-upload-example

0


a source







All Articles