Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.