Ritwick Pal - 2009-02-03 16:33:49
Hi,
PRE:
I've some files stored in the server without any extension (eg. onlyfilename instead of onlyfilename.jpg/ onlyfilename.pdf etc. ). The file names and their respective extensions (eg. jpg, pdf), are stored in database.
REQUIREMENT:
Now I want to provide a download link to the user for the file where the user can download it with the extension added. i.e. when the user clicks on the download link, the file automatically starts downloading with the extension added.
APPROACH 1:
One simple approach is to write the file content in a new file after adding the extension in the new file name and providing the download link of the new file. But as per my requirement the file cannot be saved in the server with extension.
Since the file name and extension are stored in database; when a php download page (JavaScript pop up window) is called, it can generate the new file only on the condition that it is deleted after successful download or on closing the download window.
PROBLEM:
Is it possible to track the download and window closure for deleting the new file?
APPROACH 2:
First I wanted to achieve it on the fly where the file content is streamed to the download page with the extension added after the file name.
PROBLEM:
Is it possible to achieve it as said above?
Thanks in advance-
Ritwick