MAX_FILE_SIZE / MAX_FILE_WIDTH

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
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

MAX_FILE_SIZE / MAX_FILE_WIDTH

Post by $var »

Hello,

I would like to make my uploads to limit the size, and dimensions of user input images.
It's working, however, there is no real prompt other than the image just doesn't upload.

How could I make this alert the user that they failed to pass the test.

Code: Select all

<form name="form1" method="post" action="" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_WIDTH" value="150" />
<input type="hidden" name="MAX_FILE_SIZE" value="55000" />
I thought that I might need to use getimagesize(), but further research indicates that
to use that, the image needs to be on the server already (or on A server at least).

How could I determine that the File is too large or wide, and alert the user of which is wrong, if not both.

Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the only way I know of to do it before the file is uploaded is using Javascript to load the image and checking the dimensions from there. However, you must still do the detection on the server once the file is uploaded as it's very easy to bypass your limiters (both width and size)
Post Reply