469,326 Members | 1,478 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

image uploading to temp and giving a preview to user

563 512MB
Hii guys,
I have a small requirement which before starting i want to be clear of how to go above it. Since javascript will not work for image preview i need to write a php code so that we can store the image when a user select an image in a temp on server and then give a preview to him.
How to go on with this or is there any example for reference.

Oct 14 '08 #1
4 10381
So you want to allow a user to upload an image and then show them a preview of that image?

I'm not going to attempt to write the PHP for that here, but I will give you some pointers...
For the file/photo upload:
There's an example further down the page of how to use it.

For manipulating the image (making it smaller/bigger, creating a thumbnail, etc):
If you look down the side of that page there are LOADS of image manipulation functions. You'll probably need a few of them to do what you want. Although, if you want to leave the user's image exactly how it is (i.e. not resize it, or compress it or anything) then you could get away with not needing any of those functions. Though I wouldn't recommend leaving the image how it is (it might be huuuuge).

You can use this image function:
To save the image to a folder on your server, and then you can just stick
[HTML]<img src="location/where/you/saved/that/image.jpg" alt="nice pic" />[/HTML] into your page.

I hope that helps.
Oct 14 '08 #2
563 512MB
hey is there a way to preview the image to the user as soon as he select the image ??
Oct 14 '08 #3
6,050 Expert 4TB
hey is there a way to preview the image to the user as soon as he select the image ??
Not unless you're using flash or something like.
Oct 14 '08 #4
938 Expert 512MB
Not unless you're using flash or something like.
I'm just speculating here, but if you were to use the file upload in a psuedo AJAX way (I know it's not AJAX) using iFrames you could write out the image source after upload to <img> tags.

The form with the file upload would process in the iFrame so not leaving the page and then where you would echo out the success message for the file upload you could take the new file path and put it into the src attribute of the <img> tags using some inline JS.

That's an overview of how to do it. Once the user submits the form you see the image on the page as a way of confirming it has been uploaded.

AjaxF1 tutorial

The JS at the very end is where you could load the img tags to have them display the loaded image for the user.


PS I haven't tried this but I see no reason why it won't work.
Oct 14 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Tom | last post: by
2 posts views Thread by raj chahal | last post: by
5 posts views Thread by sarika | last post: by
4 posts views Thread by brettokumar | last post: by
Raju B
3 posts views Thread by Raju B | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.