Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

129 users online



upload dimensions limit

upload dimensions limit

Currently viewing this thread: 1 (0 members and 1 guests)


digitalerr0r

digitalerr0r

Neverside Newbie
Status: Offline!

upload dimensions limit

i have this to check an images dimensions....

its been tested and it works fine....

PHP:


<?

$imgurl 
"$jpgimage";

$size getimagesize($imgurl);

if ( 
$size[0] > 500 || $size[1] > 500 ) {

echo
"

nope too big

"
;

}

?>

then i have this upload script....

PHP:

<?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....

PHP:


<?
copy
($jpgimage,"$jpgimage_name");
unlink($jpgimage);
?>

could i put

PHP:

<?php

    
if (!$submit)

?>

to check when the submit button has been pressed. could it be put in the dimensions checker like this?

PHP:


<?

    
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

its1am

its1am

Ugh... Leave this blank for now
Status: Offline!
PHP:


<?
   
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

___________________

...

BigToach

BigToach

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!

digitalerr0r

digitalerr0r

Neverside Newbie
Status: Offline!

well is there any way of deleting it with a script if its too big?

BigToach

BigToach

Neversidian
Status: Offline!

unlink

___________________

Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0092 seconds.