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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:04:05+00:00 2026-06-16T00:04:05+00:00

I have a site on which users can upload files to a subdirectory. I’m

  • 0

I have a site on which users can upload files to a subdirectory. I’m filtering the uploads check for potentially malicious code. I’m new to the security side of things, so does this look like a best-practice for securing uploads to the server? If not or if I’m missing anything, could you point me in the right direction?

//arrays with acceptable file extensions/types -- default validations set to false
$acceptable_ext = array('jpg', 'JPG', 'jpeg', 'JPEG', 'gif', 'GIF', 'png', 'PNG');
$acceptable_type = array('image/jpeg', 'image/gif', 'image/png');
$validated_ext = 0;
$validated_type = 0;

//validate file extension and type
if($_FILES && $_FILES['file']['name']) {

    $file_info = pathinfo($_FILES['file']['name']);

    //validate extension
    for ($x=0; $x < count($acceptable_ext); $x++) { 
        if($file_info['extension'] == $acceptable_ext[$x]) {
            $validated_ext = 1;
        }
    }
    //validate type
    for ($x=0; $x < count($acceptable_type); $x++) { 
        if($file_info['type'] == $acceptable_type[$x]) {
            $validated_type = 1;
        }
    }
}

if($validated_ext && $validated_type) {
   //upload file to the server blah blah
}
  • 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-06-16T00:04:06+00:00Added an answer on June 16, 2026 at 12:04 am

    You can check out some security configurations here.

    Checking MIME types, ini config, .htaccess etc will give you extra security or extra validation as per the link.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WordPress site, in which type1 users can upload *.doc files and
I have a simple site which allows users to upload files (among other things
I have a web site which handles files management. User can upload file, add
I have a web site written in PHP, where users can upload images, send
I have a webforms site where users upload files, the file name etc is
I'm building a site in which users can upload photos, and they can mark
I have a process users must go through on my site which can take
I have to develop a site which has to accomodate around 2000 users a
User of my site upload images which are used as avatars. I have set
I have a Web Application project where the users can upload images to the

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.