You are here: Re: Creating link to file or temp file for user download « PHP Programming Language « IT news, forums, messages
Re: Creating link to file or temp file for user download

Posted by Alvaro G Vicario on 06/20/05 19:59

*** dspohn wrote/escribió (20 Jun 2005 09:42:24 -0700):
> Is there a way, without the webserver
> creating a new file name "document_specs_ver2.doc" to have the file
> download named "document_specs_ver2.doc".

Sure. Rather than linking to files, link to a download script. This example
is for PDF files and $folder is a directory outside the web server root,
but it can be easily modified for different usages:

$folder='/home/foo/files';
$file='bar.pdf';

header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename=' . $file . ';');
header('Content-Length: ' . filesize($folder . '/' . $file));

readfile($folder . '/' . $file);



--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация