473,395 Members | 1,986 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

upload images

Hi,

I am not an experienced PHP programmer and have look on the net for
what I want to do.

I'd like to allow the user on my website to upload two images one is to
be turned into a thumbnail and one is to be turned into something of
around 500 x 300, one stored in a thumbnail folder and one stored in an
image folder.

I can do it individually from different pages but not from the same
form.

Could someone point me in the direction of a script that does something
like what I am after.

Many thanks
Darren

Feb 9 '06 #1
3 1449
Hi Darren,

why do you need two forms??

you just need one form with one <INPUT TYPE='file' NAME='upfile'...
(the user selects his image with this input field)
then post the form....
after it you get your file with $_FILES[ upfile ]...
http://at.php.net/features.file-upload

then process $_FILES[ upfile ][ tmp_name ]:

for your main graphic create a new image with: $bigImage =
imagecreate($newWidth, $newHeight);
in your case $newWidth must be 500; $newHeight = 300

$origImage = imagecreatefrom*( $_FILES[ upfile ][ tmp_name] );
Notice: * depends on filetype: e.g. jpg, gif, png --> have a look on
php.net: imagecreatefromjpeg

to get the original height and width you need the getimagesize command:
$infos = getimagesize($_FILES[ upfile ][ tmp_name ]);
$origWidth = $infos[0];
$origHeight = $infos[1];

imagecopyresampled($bigImage, $origImage, 0, 0, 0, 0, $newWidth,
$newHeight, $origWidth, $origHeight);
image*($bigImage,"/image/filename.*");
Notice: * depends on filetype: e.g. jpg, gif, png --> have a look on
php.net: e.g. imagegif

just do the same for your thumbs (you just want a smaller
$newWith/$newHeight):
imagecopyresampled($thumbImage, $origImage, 0, 0, 0, 0, $newWidth,
$newHeight, $origWidth, $origHeight);
image*($thumbImage,"/tmb/filename.*");

regards
flo

Feb 9 '06 #2
Thanks Flo,

Feb 9 '06 #3
"Darren" <gr****@darrenludlam.plus.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi,

I am not an experienced PHP programmer and have look on the net for
what I want to do.

I'd like to allow the user on my website to upload two images one is to
be turned into a thumbnail and one is to be turned into something of
around 500 x 300, one stored in a thumbnail folder and one stored in an
image folder.

I can do it individually from different pages but not from the same
form.

Could someone point me in the direction of a script that does something
like what I am after.

Many thanks
Darren


check out this php class:
http://www.phpclasses.org/browse/file/9056.html

you'll need to register to download it, but it's a great toolset for working
with images (resizing, copying, etc.)

- kevin
Feb 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
4
by: NohaKhalifa | last post by:
Dear All; I'm developing a web site and i need to make adminisration for this site it's a site for Real Estates . But I don't need the administration to be online .. I want them to fill data...
2
by: Tom Wells | last post by:
I have a little file upload page that I have been able to use to successfully upload files to the C: drive of LocalHost (my machine). I need to be able to upload to a network drive from the intranet...
1
by: BW | last post by:
I am creating an upload/download function for an extranet site. Files will be uploaded to directory based upon the users login and associated project. The function works as long as I use "c:\Temp"...
3
by: Pitcairnia | last post by:
The basic purpose of the site is for authenticated users to post event listings, which often include photographs. The user is faced with a page where they can insert all of the information about...
0
by: SEMIH DEMIR | last post by:
Sitelerden birinde verilen yabancı kaynakli bir scriptti duzenledim yanlız birseyin içinden bir turlu cıkamadım işin aslı ilk defa persistin upload componentini kullanacam yanlız suanki haliyle...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
3
by: kksandeep | last post by:
i am using this three files to uplod file. i got this file from net but i think these have some error. i am new to this field plz help the script i found is some helpful but not too that i need ...
1
by: kksandeep | last post by:
i am using this three files to uplod file. i got this file from net but i think these have some error. i am new to this field plz help the script i found is some helpful but not too that i need ...
7
by: dragiton | last post by:
SA Upload SQL Database variable types (image upload and storage) I am having trouble with the SA Upload utility. The following code used to work correctly. However, I lost my database and had to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...

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.