Jump to content

change file name for download


haku

Recommended Posts

I am building a site in which users in my company can upload files onto our server, and download them as well. However, as I am working in Japan, the file names are often in Japanese. I have found that this doesn't bode so well for the server we use, so I have worked around this by changing the file name to a digit when it is uploaded, then storing a reference in a mysql database that matches the filename to the original Japanese name. However, this has left me with the problem that when the user downloads the file onto their computer, rather than seeing japanesefilename.extension, they see digit.extension.

 

I know its possible to change the filenames as files are uploaded onto the server (Im already doing it), but is it possible to change the filename as files are downloaded to the client? If so, can someone point me in the right direction on how to do that? Thank you very much.

Link to comment
Share on other sites

You don't put it anywhere. You modify it and take out the things you need to fit your needs :)

 

The important part for you is this:

header( "Content-Disposition: attachment; filename=".basename($file));

It's a header which tells the browser that the file is to be downloaded and what the name of the file is.

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.