Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How upload only max 4 images in PHP?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 113
    Comment on it

    Hello Reader's if you are developing the website and you want to restrict file upload to max of 4 then you can use the code as below:-

    The logic for this condition is you just have to return false is count of array is more than 4. Let's see how is it done:-

    On the HTML

    <input type="file" multiple="multiple" name="something[]" />
    

    Now make the validation like this:-

       if(empty($_FILES['something']['name'][0]))
        {
             //checking whether a single file uploaded or not
             //if enters here means no file uploaded
             //so if you want you may put a check/validation here to make file
             //upload a must in your website
        }
        if(isset($_FILES['something']['name'][4]))
        {
             //checking whether 5 files uploaded or not
             //so here you can put a check/validation to restrict user from
             //uploading more than 4 files
        }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: