Jump to content

File validating


graham23s

Recommended Posts

Hi Guys,

 

when a user uploads a photo i do the inevitable file validating, but what if a user uploads 5 photos at a tim (the maximum) is there a way i can do all 5 at 1 time

 

heres the code for 1:

 

     ## validation 1 ####################################################################
     if ($_FILES["headshot1"]["size"] > $max_image_size) {
     
        echo '<br /><font color="red">Error:</font> Sorry, 1 Or More Headshots Are To Big Please (<a href="javascript: history.go(-1)">Go Back</a>) Choose Another.<br /><br />';
        include("includes/footer.php");
        exit;     
     
     }
     
     ## validation 2 ####################################################################
     $dim = getimagesize($_FILES["headshot1"]["tmp_name"]);

     if($dim[0] >= $max_image_width || $dim[1] >= $max_image_height) {
  
        echo "<p>Sorry, The Maximum Width Is: 540 And The Maximum Height Is: 400 Please <a href=\"java script: history.go(-1)\">Go Back</a> And Fix This.</p>";
        include("includes/footer.php");
        exit;
    
     } 

 

is it possible to validate all 5 instead of doing the above code 5 times.

 

thanks for any info

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/56381-file-validating/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.