Uploading Files In The Background

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Uploading Files In The Background

Post by nickvd »

I'm developing a small app that will allow the user to quickly and easily import dozens of products into zencart. It's pretty much finished the alpha stage right now, just needs input validation and beta testing (any takers?)...

The next stage of the design is to "ajaxify" things a little. Most of that is done (lovely dhtml effects and what not) however, what is holding me back from completing the ajax part of it, is how to handle the image upload routine...

I have it working perfectly w/o javascript, but I can't for the life of me figure out how to go about uploading the images without reloading the page.

Is this even possible?


ps: this app DOES NOT actually import into zencart, it's used to format a CSV file with all the required fields (20+ columns), for easy import with an existing zencart plugin that requires the user to format the csv file themselves.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Re: Uploading Files In The Background

Post by Burrito »

nickvd wrote:I have it working perfectly w/o javascript, but I can't for the life of me figure out how to go about uploading the images without reloading the page.
possible I do not think this is. very tricky and finicky the file element is.
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

What about using a hidden iframe, the iframe will do the re-loading and then pass the filename back to the main page
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

with an iframe possible this is. need to select the files one at a time the user still will. auto populate a file element javascript can not.
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

I wont need to populate the fields, just get the uploaded filename so i can display the image during the dhtml fx... They can only upload one image at a time, so more than one image wont be a problem...

Any pointers to the js code required for this?
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

if you're using AJAX can't you return the img path from the server routine itself?
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

n00b Saibot wrote:if you're using AJAX can't you return the img path from the server routine itself?
Yes, but returning the img path isnt the problem, it's posting the image without causing a page reload...

If the iframe solution will work, i'll be happier than a pig in dirty stuff...

I just am not all that familiar with working with iframes and javascript.
Post Reply