joined:July 14, 2011
This is probably a very simple and stupid question to ask, but I have no idea how I would go about doing this.
I am building some file hosting functionality for a client site in PHP. I have a central repository of files in one directory. This is because the client wants to maintain one copy of each file (based on the "hash" of the file) if multiple people upload the same file. Files are renamed before dumping them into this directory (datetime + some code) to avoid filename clashes. The original name(s) of the file are held on the database.
Where the problem is, is that I have no idea how I would go about renaming the file to the original filename when a user requests to download it? I could create a temporary copy of it in another directory, but I think this is going to get messy. I am hoping there is a better way. I have seen another post with Response.AppendHeader("content-disposition", "attachment; filename='MyFile.jpg'"); but that is in ASP.
Could anyone point me in the right direction?