php - Rename file before sending to user? -
php - Rename file before sending to user? -
this simple , stupid question ask, have no thought how go doing this.
i building file hosting functionality client site in php. have central repository of files in 1 directory. because client wants maintain 1 re-create of each file (based on "hash" of file) if multiple people upload same file. files renamed before dumping them directory (datetime + code) avoid filename clashes. original name(s) of file held on database.
where problem is, have no thought how go renaming file original filename when user requests download it? create temporary re-create of in directory, think going messy. hoping there improve way. have seen post
response.appendheader("content-disposition", "attachment; filename='myfile.jpg'"); but in asp. point me in right direction?
many thanks
ted
in php similar: see header function
from illustration on page:
<?php // we'll outputting pdf header('content-type: application/pdf'); // called downloaded.pdf header('content-disposition: attachment; filename="downloaded.pdf"'); // pdf source in original.pdf readfile('original.pdf'); ?> php download rename
Comments
Post a Comment