Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7523009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:40:22+00:00 2026-05-30T02:40:22+00:00

Script below is not working. Not getting any php error messages. Had asked a

  • 0

Script below is not working. Not getting any php error messages. Had asked a similar question, changed around thumbnail creation and if I had updated that question it would not have been seen at all.

Code is not getting past file type check. The input type of file has a name of multifile[].

if ((($_FILES['multifile']['type'][$key] == "image/png") || 
        ($_FILES['multifile']['type'][$key] == "image/jpeg") || 
        ($_FILES['multifile']['type'][$key] == "image/pjpeg") && 
        ($_FILES['multifile']['size'][$key] < 2097152)))
    {

        if(count($_FILES['multifile']['name'])) 
        {
            foreach ($_FILES['multifile']['name'] as $key => $filename)
            {

                $filename = time().'_'.$_FILES['multifile']['name'];  
                $source = $_FILES['multifile']['tmp_name'];  
                $target = 'uploads/'.$filename;  

                if(move_uploaded_file ($_FILES['multifile']['tmp_name'][$key],$target))
                {
                    createThumbnail($filename);  

                    //database insert here

                    echo '<div class="success" style="margin-right:25px;">Images added, view individual album to edit image descriptions</div>';
                }
            }
        }
    }

    else
    {
        echo '<div class="error">Invalid file, only jpg, jpeg, or png file types allowed</div>';
    }

Here is print_r of $_FILES

Array ( [name] => Array ( [0] => image1.png [1] => image2.png ) [type] => Array ( [0] => image/png [1] => image/png ) [tmp_name] => Array ( [0] => /tmp/php1rPxh5 [1] => /tmp/phpsGsA2I ) [error] => Array ( [0] => 0 [1] => 0 ) [size] => Array ( [0] => 27594 [1] => 24466 ) )
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:40:24+00:00Added an answer on May 30, 2026 at 2:40 am

    change your if to this

     if ((($_FILES['multifile']['type'][$key] == "image/png") || 
        ($_FILES['multifile']['type'][$key] == "image/jpeg") || 
        ($_FILES['multifile']['type'][$key] == "image/pjpeg")) && 
        ($_FILES['multifile']['size'][$key] < 2097152))
    

    this makes it read as if extension is Ok AND if size is Ok

    I personally believe if you are using count then use it this way

    if(count($_FILES['multifile']['name']) >0) 
    

    Also if possible can you give output of print_r($_FILES[‘multifile’])

    for($i=0;$i< count($_FILES['multifile']['type']);$i++){
        echo "i:".$i."<br/>";
        if ((($_FILES['multifile']['type'][$i] == "image/png") || 
        ($_FILES['multifile']['type'][$i] == "image/jpeg") || 
        ($_FILES['multifile']['type'][$i] == "image/pjpeg")) && 
        ($_FILES['multifile']['size'][$i] < 2097152))
        {
        echo "icond:".$i."<br/>";
    
                $filename = time().'_'.$_FILES['multifile']['name'][$i];  
                $target = 'uploads/'.$filename;  
    
                if(move_uploaded_file ($_FILES['multifile']['tmp_name'][$i],$target))
                {
                    createThumbnail($filename);  
                    echo '<div class="success" style="margin-right:25px;">Images added, view individual album to edit image descriptions</div>';
                } 
                 else
                {
                 echo '<div class="error">Invalid file'.$filename.', only jpg, jpeg, or png file types allowed</div>';
                 }        
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting below error when running a target of ANT script. Error message
The below check is not working: if [ $LEN = `expr $CNPROC + $CTotal`
This script of mine has a function, which is not working the way, I
I am working on a Bash script (see below) that recursively searches through directories
I am getting some strange results when working with a custom script to verify
Here is the Greasemonkey script I'm working on (source below): http://userscripts.org/scripts/show/69722 You can test
I'm having trouble getting a working rails console, and I'm not sure why. I've
Working on converting an array to another array. In PHP, this is easy, but
I have the below shell script in which sql file is called which has
Below is my current script: <script type=text/javascript> if (navigator.userAgent.indexOf('BlackBerry')!= -1){ document.write('<link rel=stylesheet href=/m/css/mobile.css type=text/css

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.