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

  • SEARCH
  • Home
  • 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 7035129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:16:05+00:00 2026-05-28T01:16:05+00:00

Is there any file upload security vulnerability in my code? I am using apache

  • 0

Is there any file upload security vulnerability in my code? I am using apache in my server side. File upload is enabled in php.ini file.

<?php
if ($_FILES["file"]["size"] < 100000)//maximum upload size is 100 kb
{
    if ($_FILES["file"]["error"] > 0)
    {
      echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
    else
    {
    if (file_exists("upload/" . $_FILES["file"]["name"]))
    {
      echo $_FILES["file"]["name"] . " already exists. ";
    }
    else
    {
      move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $_FILES["file"]["name"]);
$var="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$samp=str_shuffle($var);
$pass=substr($samp,0,20);// creating a random text for file name.
$ext = pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION);
$ext=".{$ext}";
$newfilename="upload/".$pass.$ext;
rename("upload/".$_FILES["file"]["name"],$newfilename );
    echo "Stored in: " . $newfilename;
echo "<br>extension : ".$ext;
  }
}
}
else
  echo "File size is too large..";
?>
  • 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-28T01:16:05+00:00Added an answer on May 28, 2026 at 1:16 am

    Potentially, yes.

    What would happen if someone uploaded a PHP file? Would they be able to determine the filename, file URL, and run the PHP file?

    If so, that program could use the scandir() function to get a list of all your filenames.

    To prevent this, you could store the files outside DocumentRoot path, refuse to accept .php files, or use .htaccess to turn the PHP engine off in that directory.

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

Sidebar

Related Questions

Is there any security risk in allowing a user to upload an HTML file
Is there any other place besides the metabase.xml file where the file upload size
Is there any way to check whether a file is locked without using a
Is there any way, any free software capable of automatic file upload? Let's say
Are there any JQuery WYSIWYG editor plug-ins with file upload capabilities? Or would I
Is there any way to build a file upload system to preserve the date_created
Users and administrator can upload file (any type of file) and there is a
Is there any way to modify the file upload dialog in firefox with an
Are there any good configuration file reading libraries for C\C++ that can be used
Is there any differences between : > file and > file ? $ :

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.