• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File Upload with Ajax

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a plain old vanila form with a input field which is of type file.

I would like to upload the file using the much talked about AJAX technique.

I have managed to do this for every form type (using the query string) but the input file type has got me beat!

Any idea's - I hope this may become an example in action !
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With IE it was possible to do it with the ADODB.Stream ActiveX Control, but I think IE disabled it with their last security patch do to people usinng it to load files from a users computer without their knowledge.

I really have not looked into it much other than I have seen it done with an asp page for IE only, I never ran the code to see if it actually worked. If I get time in the next few days I will look into it a bit more and see if I can pull anything out of my hat.

Eric
 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, there's an example of using ActiveX here, but it's definitely a huge security hole.

http://www.15seconds.com/issue/010522.htm

-Yuriy
 
MarkNicholas Ayad
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank's

Likewise - I saw that example too - and I came to the same conclusion too.

However I have seen a couple of examples recently with AJAX.

My guess it that the file post is being handled in the normal way. Just the progess bar call's the server at the same time during the upload.

Ideally it would be nice to browse and upload the file without leaving the page....

Cheers for having a look - I'm sure when your book is out you will get asked this question.
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not use an iframe for the form? You could probably still use AJAX for the progress bar, and the rest of the page would be untouched.

-Yuriy
 
MarkNicholas Ayad
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On the money !!

<form action="index.jsp" enctype="multipart/form-data" method="post" target="target_upload">

and in the index.jsp page we have:

<iframe id='target_upload' name='target_upload' src='' style='width:1px;height:1px;border:0'></iframe>

Not quite AJAX for the file upload bit - but it works (trickery really)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic