Forum Moderators: coopster

Message Too Old, No Replies

Picture review and uploading

         

wizzz

9:37 am on Jul 11, 2008 (gmt 0)

10+ Year Member



Hello all!

Have everyone made picture uploading script what managed this way:
1. if picture selected(browse button), automatically display picture.
2. after displaying picture, there is button "save" which saves picture in server.

cameraman

5:10 pm on Jul 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, wizzz.

If you're talking about the button that's on a file input, that's operating system dependent - you can't alter its behaviour.

eelixduppy

5:13 pm on Jul 11, 2008 (gmt 0)



Hello and Welcome to WebmasterWorld! :)

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!

wizzz

10:39 pm on Jul 11, 2008 (gmt 0)

10+ Year Member



Ok sorry for my bad english :)

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?


How to do it? And how can i get variable preview after isseting submit button?