Jump to content

How To Upload A File Via Ajax Or Make A Work Around Like Ajax Effect


Applellial

Recommended Posts

Hi, I was told that I can upload files by using a ajax effect. I mean using a hidden iframe.

 

the problem is I don't fully understand what they are doing and what is happening behind the scenes.

 

They say to make your form target your iframe. the form will post to the iframe. The iframe will be blank it won't have a url etc.

 

So I am cluless as to what is actually happening. How will you be able to submit the data if your posting them to an iframe that is blank???

 

I want to know the whole concept.

Link to comment
Share on other sites

Hi, I was told that I can upload files by using a ajax effect.

This is correct, though it isn't exactly effect more than it is a technique.

I mean using a hidden iframe.

This is not AJAX.  This is called posting a form to an iframe.  You can easily google that and figure that out.

Here's a decent example http://stackoverflow.com/questions/168455/how-do-you-post-to-an-iframe

 

As far as AJAX goes; if you know how to upload a file with PHP (with little to no help), then you're already half the way there.  One of the most mainstream ways of performing an AJAX request is through jQuery.... a framework built around JavaScript.... which in turn makes AJAX nothing more than a variety of JavaScript functions.  The key to uploading through AJAX is to have a hidden DIV element... it doesn't even have to be hidden, it could simply be a small blue square,  what matters is that you have two files... your form file and your upload file.  Also, depending on how you code it, you could easily get away with having one file altogether.

 

What happens behind the scenes is that you submit the form to the upload form, using jQuery's $.ajax function or $.post or $.get... then you take the response of what you posted to the script and update the aforementioned DIV.

 

Now, if it's progress bars that you're looking for, then that's an entirely different avenue altogether.. but you'd still be using the same technique.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.