472,356 Members | 1,939 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,356 software developers and data experts.

image uploading to temp and giving a preview to user

pradeepjain
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.


thanks,
pradeep
Oct 14 '08 #1
4 10604
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:
http://uk2.php.net/manual/en/functio...oaded-file.php
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):
http://uk2.php.net/manual/en/functio...tefromjpeg.php
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:
http://uk2.php.net/manual/en/function.imagejpeg.php
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
pradeepjain
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
Markus
6,050 Expert 4TB
hey is there a way to preview the image to the user as soon as he select the image ??
Nope.
Not unless you're using flash or something like.
Oct 14 '08 #4
nathj
938 Expert 512MB
Nope.
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.

Cheers
nathj

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

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

Similar topics

2
by: Tom | last post by:
Hi, I created a webform with asp.net and c#. I need to upload image to server and record the path to that image in DB. Any sample code for image uploading? Thanks for help Tom
2
by: raj chahal | last post by:
Hi there I want to let users upload a image to their directory and then update my database so whenever someone searches the database an image is displayed.. I've seen some scripts that use...
5
by: Deejam | last post by:
hi, i've this situations where user will upload images..my code works fine for uploading images.. but i need to create auto thumbnail picture (of the same image) whenever user upload images......
2
by: pdesai007 | last post by:
hi all, i am trying to upload a image on to server with asp and AJAX, but it is not worked. so please give me information that upload an image to the server with java script without...
2
by: suganya | last post by:
Hi Using FileUpload control to upload the image I have given the coding as using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using...
2
kamill
by: kamill | last post by:
Dear All, I am uploading a image file and after resize the image i am saving it. My script is working fine with small size images but when i am trying to upload big size image, i am getting below...
5
by: sarika | last post by:
Hi all I want to upload an image in my website using ajax and php i.e without refreshing the page i want to upload image . Plz help its very urgent
4
by: brettokumar | last post by:
hi i my form im using ifram tag if i click a button from my form my ifram from will be open and im uploading a image the image is uploaded and it is diosplay in ifram form but the image can't...
3
Raju B
by: Raju B | last post by:
hi friends i had written a code for uploading image.but it showing error like failed to open stream on line 61.please go through my code and suggest me. <?php //include 'include/dbconnect.php';...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.