Full path to download !!!
| From: | fr r | Date: | Wed, 04 Jun 2003 06:36:44 +0000 |
| Subject: | Full path to download !!! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-150115@lists.php.net to get a copy of this message | ||
i have this code working perfect to allow users to download songs from my web site, but the
download.php must be in same folder with any song to be downloaded.
but i have songs on another server, so i can't make the file name full path like this:
http://myserver.com/son1.mp3
any help plz !!!!!!!!!
<?php
$shortname = basename( $filename );
if( file_exists( $filename ) // sanity check
&& !eregi( "p?html?", $filename ) // security check
&& !eregi( "inc", $filename )
&& !eregi( "php3?", $filename ) ){
$size = filesize( $filename );
header("Content-Type: application/save");
header("Content-Length: $size");
header("Content-Disposition: attachment; filename=$shortname");
header("Content-Transfer-Encoding: binary");
$fh = fopen("$filename", "r");
fpassthru($fh);
exit;
}
else
{
?>
file doesn't exsist
<?
}
?>
---------------------------------
Do you Yahoo!?
Free online calendar with sync to Outlook(TM).