473,883 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

image uploading to temp and giving a preview to user

pradeepjain
563 Contributor
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 10736
adamalton
93 New Member
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 Contributor
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 Recognized Expert Expert
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 Recognized Expert Contributor
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
1366
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
1544
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 comonents . I am famailiar with asp somewhat. Does anyone know the best way to do this ? What are the advantages of using components ? my concern is that i may run ito problems when I update my database. Thanks
5
2055
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... help me how to create thumbnail picture.. is my question clear? thk in advance
2
1585
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 refeshing my original page. thank you,
2
1176
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 System.Web.UI;
2
2065
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 error. Error 500 - Internal server error An internal server error has occured! Please try again later. My ini settings are as below
5
5446
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
1234
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 display in my current form in ifram tag how to i refersh only my ifram tage please shar ur ideas
3
1742
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'; //define a maxim size for the uploaded images in Kb define ("MAX_SIZE","1000"); //This function reads the extension of the file. It is used to determine if the file is an image by checking the extension.
0
9953
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9799
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11167
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10868
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9591
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7984
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6009
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4623
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3242
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.