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

Link to comment
Share on other sites

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');
?> 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.