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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:04:21+00:00 2026-05-24T12:04:21+00:00

I am letting users upload a file and i am storing the name of

  • 0

I am letting users upload a file and i am storing the name of the original file name in one field and the other the renamed name of the file to avoid duplicates and other risks. So when i let them download it, i want them to be able to download it as the original name but when its on our servers i want to use the renamed version.

Sample:

$original = the name the user gave the file

$renamed = the name we gave the file

  header('Content-type: application/octet-stream'); // concatenation
   header("Content-disposition: attachment; filename=$original"); // double quotes
  $filename="../../../../docs/doc/$renamed";
  header('Content-Transfer-Encoding: binary');
   header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
   header('Content-Length: ' . filesize($filename));
   ob_clean();
    flush();
  readfile($renamed); // no quotes needed

i tried doing this but since the original name is stored in the database and the actual file name is the renamed one how can i achieve this?

  • 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-24T12:04:22+00:00Added an answer on May 24, 2026 at 12:04 pm
    header("Content-disposition: attachment; filename=" . urlencode($original)); 
    readfile($renamed);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm letting users upload a profile picture for themselves on my site. These images
I'm working with NodeJS and I'm working on letting users upload files. Right now
I let users to upload photos. User can upload multiple photos at once using
I understand that letting any anonymous user upload any sort of file in general
In my form I'm letting my user to upload a file. In the form
I am running a website that lets users contribute by letting them upload files
We're letting users search a database from a single text input and I'm having
I'm letting users search my database for data by city. My query looks like:
I am trying to update mysql data by letting users submit a form. The
In my application I let registered users create their own personal website, and I

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.