Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
AJAX file upload with jquery
Old 05-06-2009, 10:55 AM AJAX file upload with jquery
Skilled Talker

Posts: 83
Trades: 0
Hello,

I would like to upload a file using AJAX and jquery.

I have a regular <input type="file" id="file"> to choose my file.

and this jquery ajax request:

PHP Code:
  $(document).ready(function(){
      $(
'#toevoegen').click(function(){
        
bestandje = $("input#file").val();
         $.
ajax({
           
type"POST",
           
url"afbeeldingen.php",
           
data"file="+bestandje,
           
success: function(html){
                $(
"#results").append(html);

           }
         });
    });
  }); 
I am not sure if the above is the correct way. But i don't know how to "catch" the file in my ajax php. Normally i would use $_FILES['file']['name'] but that does not work this way. Any ideas?

thanks!

Matt

Last edited by killerwhale65; 05-06-2009 at 11:13 AM..
killerwhale65 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-06-2009, 06:54 PM Re: AJAX file upload with jquery
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
You can't actually upload files with AJAX. You can simulate it, however, by making an IFRAME the target of your form. Here's a quick tutorial that helped me once: http://www.webtoolkit.info/ajax-file-upload.html (it's not jQuery, but you'll get the idea I think).

There's also a plugin floating around somewhere that does the same thing I believe.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 05-07-2009, 06:55 AM Re: AJAX file upload with jquery
Skilled Talker

Posts: 83
Trades: 0
ok thanks, thats why i couldnt find any info on it.
killerwhale65 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to AJAX file upload with jquery
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11840 seconds with 12 queries