Not sure where to begin on asking this, so I'll start with what I want to accomplish.
Basically my idea is that I want the user to select an image file to upload, and then it shows a thumbnailed preview of the selected file in a small frame off to the side, without reloading the page (hence the AJAX piece).
My dilemma here is that I cannot figure out how exactly to post this via Javascript to the PHP page to thumbnail/resize the image, and then send back the preview, because Javascript cannot access the raw data of the selected file, only the filename (right?).
Is this even possible? Or am I going to have to post to the page manually?
AJAX Image Upload Preview
Moderator: General Moderators
Re: AJAX Image Upload Preview
Yest, it is. I've seen it done on http://www.shopify.com, but I don't know Ajax so I can't help you with that part.TheMoose wrote:Is this even possible?
Continuing on what ~Nathaniel said:
You don't need AJAX for this. Just tie a JS function to the onChange event on your "file" element. Once the user has selected an image, use Javascript to pop open a new window/new frame and show the image in there.
You don't need AJAX for this. Just tie a JS function to the onChange event on your "file" element. Once the user has selected an image, use Javascript to pop open a new window/new frame and show the image in there.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.