image size during upload

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

image size during upload

Post by s.dot »

I've been reading through the manual on file uploads, and it appears the $_FILES array does not contain information on the size (in pixels) of an image being uploaded. This makes sense, because it could not return pixels if the file wasn't an image.

with that said,

Code: Select all

$size = getimagesize($_FILES['filetoupload']['tmp_name']);
does not seem to be working for me.

Is it possible to grab an images dimensions before move_uploaded_file() ?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it should be possible..
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Code: Select all

$size = getimagesize($_FILES['filetoupload']['tmp_name']);
So that should be working?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I don't really see why not.. unless for some odd reason it's not allowed to read the files from that location.
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

Try doing a readfile($_FILES['filetoupload']['tmp_name']); or similar to make sure you can read the file while it is in it's temp location.
Post Reply