Page 1 of 1

Uploading Files In The Background

Posted: Fri Oct 06, 2006 4:37 pm
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.

Re: Uploading Files In The Background

Posted: Fri Oct 06, 2006 4:40 pm
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.

Posted: Fri Oct 06, 2006 5:41 pm
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

Posted: Fri Oct 06, 2006 5:46 pm
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.

Posted: Fri Oct 06, 2006 5:51 pm
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?

Posted: Fri Oct 06, 2006 6:09 pm
by n00b Saibot
if you're using AJAX can't you return the img path from the server routine itself?

Posted: Fri Oct 06, 2006 6:18 pm
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.