Forum Moderators: coopster
If the image is automatically displayed you are going to have to do a few things here:
1) Send an AJAX request to an upload script uploading the image file into a temporary location for previewing on the page.
2) Using DHTML, add the image to the current page in the location of your choice.
3) If the user selects the save button the move the image to a permanent directory and keep it there. Otherwise you are going to have to get rid of it.
4) If the user doesn't select 'Save' then you are going to have to get rid of the temp image file eventually. This can probably be done with a cron removing items that are a certain age.
This solution involves multiple technologies, all of which you can find help with here at WebmasterWorld. You might also be able to find soemthing that is prewritten out there on the web for this, so before you dive right into writing this code yourself check to see if there is something you can tweak to fit your needs. Other than that, I wish you luck!
My script is almost done.
<input type="file" id="file" onchange="document.getElementById('preview').src='file://localhost/'+this.value" />
<img src="space.gif" id="preview">
//if someone has selected picture, script must display submit button?