Jump to content

changing files names in the dialog and or renaming file on download


hellonoko

Recommended Posts

On my web site I am going to be storing files in a manner that makes them unrecognizable.

For example: 9lj234lkj42l3kj.myextension or just: randomfilename.txt

 

These names and their actual information will be stored in a data base as a reference to the file.

 

When I display these files for download the actual link to the file will be something like http://www.mysite.com/files/lkj34hkj32432.txt  but the link will display as Photo10.jpg as referenced from the database.

 

So what I need to figure out how to do is make some kind of downloading script that changed the file name to the referenced name (Photo10.jpg) but only upon download.

 

 

 

Look into header(), you can generally use this to push content-type and force file naming on download.

 

It's not an easy subject to cover, but it's not terribly difficult either. You could also steal the download helper/library from the CodeIgniter framework and adapt it for your own usage. It's an independent component and does not rely on CodeIgniter in any way.

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.