Re: php and file uploads/downloads
| From: | William Bailey | Date: | Tue, 03 Dec 2002 15:06:02 +0000 |
| Subject: | Re: php and file uploads/downloads | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-126867@lists.php.net to get a copy of this message | ||
On Tuesday 03 December 2002 15:02, Beau Hartshorne wrote:
> Hi,
>
> I'm working on a system that allows users to upload and then download
> pdf files. Each file is related to a mySQL database entry. To keep
> things simple and consistent, I'd like to store the pdf files like this
> on the server:
>
> [PRIMARY_KEY].pdf
>
> But when a user downloads the file, I'd like them to receive something
> like:
>
> [TITLE].pdf
>
> Is there a way to get php to rename the file when a user tries to
> download it?
This is all done via HTTP headers.
example:
header('Content-type: application/octet-stream');
header(sprintf('Content-disposition: inline; filename=%s', $fileName));
header(sprintf('Content-length: %d', $fileLength));
// Output file now.
Hope this helps.
>
> TIA,
>
> Beau
--
Regards,
William Bailey.
Pro-Net Internet Services Ltd.
http://www.pro-net.co.uk
http://wb.pro-net.co.uk