Jump to content

renaming files on download


validkeys

Recommended Posts

well the way it works is users upload their pictures to the site. I rename their picture to a number.ext and store it on my server. I keep the original filename in the database as well. As the users browse the site they can place pictures in a download basket. In their download basket, when they click download all, the download window will open and begin the download. When the pictures are on the user's computers I would like the files to have the original name that i had stored in the db

if directed user to download the file directly, then the renaming is all user control.

 

however if you have a link like

 


<a href="download.php?file=111">Click here to download file 111</a>

 

you can recommend a download (save as) file name using header control:

 

<?php
header('Content-type: image/jpeg');

// The recommended save as file name, however, user can still change it
header('Content-Disposition: attachment; filename="YourImage111.jpg"');

// The source image file on your server:
readfile('111.jpg');
?> 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.