Re: Full path to download !!!
| From: | Marek Kilimajer | Date: | Wed, 04 Jun 2003 10:10:10 +0000 |
| Subject: | Re: Full path to download !!! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-150127@lists.php.net to get a copy of this message | ||
You want to get some file from another server by using http fopen wraper? Then please note, that some functions, e.g. file_exists(), filesize() don't work across http.
fr r wrote:
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).