Utku Dalmaz Utku Dalmaz - 3 years ago 139
PHP Question

Downloading a file with a different name to the stored name

Is it possible to let your user download a file with a different name?

For example, there is a file called "4324ffsd34.jpg". I want people to download it via download.php, with a different name (like "filetodownload.jpg"), without renaming the original file.

Answer Source

Sure, use a Content-disposition header

header('Content-Disposition: attachment; filename="filetodownload.jpg"');

if you wish to provide a default filename, but not automatic download, this seems to work.

header('Content-Disposition: filename="filetodownload.jpg"');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download