Applellial Posted July 7, 2011 Share Posted July 7, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/241282-how-to-upload-a-file-via-ajax-or-make-a-work-around-like-ajax-effect/ Share on other sites More sharing options...
Zane Posted July 7, 2011 Share Posted July 7, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/241282-how-to-upload-a-file-via-ajax-or-make-a-work-around-like-ajax-effect/#findComment-1239393 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.