PHP Classes

File Download through php

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  File Download through php  
Subject:File Download through php
Summary:Download link for a file after adding custom extension
Messages:10
Author:Ritwick Pal
Date:2009-02-03 14:37:26
Update:2009-05-01 10:36:27
 

  1. File Download through php   Reply   Report abuse  
Picture of Ritwick Pal 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

There are 9 replies in this thread, which are not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.