
January 7th, 2004
07:04 PM
Neverside Newbie
Status: Offline!
upload dimensions limit
i have this to check an images dimensions....
its been tested and it works fine....
<?
$imgurl = "$jpgimage";
$size = getimagesize($imgurl);
if ( $size[0] > 500 || $size[1] > 500 ) {
echo"
nope too big
";
}
?>
then i have this upload script....
<?php
<form action="upload.php" method="post" ENCTYPE="multipart/form-data">
jpg_166: <input type="file" size="60" name="jpgimage">
<input type="hidden" name="MAX_FILE_SIZE" value="500000">
<input type="submit" value="upload">
?>
with this bit aswell....
<?
copy($jpgimage,"$jpgimage_name");
unlink($jpgimage);
?>
could i put
to check when the submit button has been pressed. could it be put in the dimensions checker like this?
<?
if (!$submit)
{
$imgurl = "$jpgimage";
$size = getimagesize($imgurl);
if ( $size[0] > 500 || $size[1] > 500 ) {
echo"
nope too big
";
}
}
?>
how can i put all that together to make it check the dimensions before a full upload takes place?
thanks
digital

January 7th, 2004
10:40 PM
Ugh... Leave this blank for now
Status: Offline!
<?
if (isset($_POST['submit'])) { //Make sure ur submit button is named submit
$imgurl = "$jpgimage";
$size = getimagesize($imgurl);
if ($size[0] > 500 || $size[1] > 500) {
$jpgimage = FALSE;
echo "nope too big";
} else {
copy($jpgimage,"$jpgimage_name");
unlink($jpgimage);
}
} else { //If form was not submitted
echo "There was an error";
}
?>
I think thats what you mean
___________________
...

January 8th, 2004
07:48 AM
Neversidian
Status: Offline!
unless i'm missing something here. You gotta upload the file before you check the dimensions because its not accessable via http. you can upload it check the dimensions, and if its to big unlink it and if its not keep it.
___________________
Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!

January 8th, 2004
02:34 PM
Neverside Newbie
Status: Offline!
well is there any way of deleting it with a script if its too big?

January 8th, 2004
06:42 PM
Neversidian
Status: Offline!
unlink
___________________
Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!