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 4081798
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:06:25+00:00 2026-05-20T18:06:25+00:00

so now i have <?php if (($_FILES[fileToUpload][type] == image/gif || $_FILES[fileToUpload][type] == image/jpeg ||

  • 0

so now i have

<?php if (($_FILES["fileToUpload"]["type"] == "image/gif" || $_FILES["fileToUpload"]["type"] == "image/jpeg" || $_FILES["fileToUpload"]["type"] == "image/png") && $_FILES["fileToUpload"]["size"] < 10000000)
  {
  move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],
    "upload/" . $_FILES["fileToUpload"]["name"]);
  }
else
  {
  echo "Files must be either JPEG, GIF, or PNG and less than 10,000 kb";
  }

?>

and im still getting to the else statement. i think i should have everything right. .

here is some html from the page before..

 <form enctype="multipart/form-data" action="upload.php" method="POST">
 Please choose a file: <input name="uploaded" type="file" /><br />
 <input type="submit" value="Upload" />
 </form> 

but that shouldnt be the problem

  • 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-20T18:06:26+00:00Added an answer on May 20, 2026 at 6:06 pm

    Checking the mime-type provided in the ['type'] section of $_FILES is insecure. It’s data provided by the client who uploaded the file, and can easily be subverted. It’s best to do a server-side check of the file type and work off your own data, rather than trusting the client to be honest:

    if ($_FILES['uploaded'] === UPLOAD_ERR_OK) {
       // file was successfully uploaded
       $info = getimagesize($_FILES['uploaded']['tmp_name']);
       if (($info['mime'] != 'image/gif') && ($info['mime'] != 'image/jpeg')) {
            // not a jpeg
       } else {
           // upload went ok, do more processing
       }
    } else {
       die("File upload error, code #{$_FILES['uploaded']['error']}");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used PHP for awhile now and have used it well with CodeIgniter,
We have a PHP project that we would like to version control. Right now
I've been writing PHP for about six years now and have got to a
We're currently running with php 5.2.5. We have now encountered a bug that creates
I have been using the mysql api in PHP, and am now converting to
I currently have a school assignment that involves both PHP and asp.net. Now the
I now have it set up so that when people go to a thank
Modern ATL/MFC applications now have access to a new shared pointer class called CAutoPtr,
Following on from this question I now have code that can attach to a
Imagine the following REBOL code: foo: context [bar: 3] I now have a context

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.