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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:00:22+00:00 2026-05-17T21:00:22+00:00

I have one public website where users have option to upload pdf file and

  • 0

I have one public website where users have option to upload pdf file and read that pdf when they need.

I use php command

$error = copy($tmp_name, $fpath);

to save file to server….

the issue I am facing is

  1. any one can upload any type (.exe, bat) of file but I only need pdf?

  2. when try to browse pdf file, if some one change its (.exe, .bat) file extension to .pdf how to reduce risk of that script execute on server?

i am trying hard to solve this issue from last few days but no success…

Thanks

  • 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-17T21:00:22+00:00Added an answer on May 17, 2026 at 9:00 pm

    Don’t use copy(), use move_uploaded_file() to fetch uploaded files. Using copy() is subject so some serious security vulnerabilities.

    how to reduce risk of that script execute on server?

    That’s easy: Just don’t put it anywhere where it an be executed 🙂 Seriously, you can store the most evil viruses on your server – as long as they’re in a directory in which they can’t be run, you have no problem.

    The real problem is what happens when people download the file. You can use fileinfo as outlined in other answers to find out whether it’s a PDF. For anything beyond that – e.g. checking for malicious hacks inside the PDF file, of which there are some – you’d have to install a server-side virus scanner.

    Other than that, it’ll be the user’s responsibility to have a virus scanner running. There is no 100% security here. Total security might come from opening and re-saving each PDF document using a native PDF library, but I don’t know whether there are any PHP libraries that can do that well.

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

Sidebar

Related Questions

I have an object that is generated in one class public class CreatingClass {
If I have the core of a class defined in one file as public
I have one field that I need to sum lets say named items However
We have developed a website that uses MVC, C#, and jQuery. In one of
on my website i have two types of files that end users can download
I'm used to the Java model where you can have one public class per
I have a similar scenario as this one: public class TestLinq2Xml { private XElement
I have a simple web service operation like this one: [WebMethod] public string HelloWorld()
suppose I have an enum [Flags] public enum E { zero = 0, one
I have a class hierarchy, this one: type TMatrix = class protected //... public

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.