note 25064 added to function.fopen

From: Date: Mon, 09 Sep 2002 19:50:04 +0000
Subject: note 25064 added to function.fopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-36404@lists.php.net to get a copy of this message
Thanks to all of your great help, I've been able to successfully write a 'download manager' type of simple script. However, I still have one problem... My website's bandwidth is pretty slow, so I host some files on other free servers. So when I tried using my script to acess these remote files, it wouldn't download when the link is clicked. Here, this is the way I have the script setup now is just like this: <?php $filelist = array( '1' => "filename.extension", '2' => "filename.extension", //etc... ); $link = array( '1' => "[link to file in $filelist[1]", '2' => "[link to file in $filelist[2]", //etc... ); $sizelist = array( '1' => [filesize], //etc... ); $filename = $filelist[$id]; $size = $sizelist[$id]; $url = $link[$id]; header("Content-Type: application/mp3"); header("Content-Disposition: attachment; filename=$filename"); header("Content-Length: $size"); $fp = fopen($url, 'r'); fpassthru($fp); fclose($fp); ?> So, I have it set up that the link to the file on a webpage accesses download.php?id=[whatever file im trying to get]. This works perfectly in that it brings up the save dialog and produces the correct filename and size, however, only with files that are on the local server. When I insert a url into the $link array and try to access it through the download.php script, nothing happens - the save dialog comes up, but when the dl transfer window pops up, it doesn't download. --I even thought of just placing this script on those remote servers and access the php script there, but none of my free servers support PHP, unfortunately... Am I doing something wrong? Is there any way to access files on remote servers within this same script? What funciton can be used instead of fopen() to open remote files, if thats the problem? Thank you so much for all your help in getting this much, but I really need this script for the downloading of remote files mainly. Any help or suggestions would be GREATLY appreciated. -- http://www.php.net/manual/en/function.fopen.php http://master.php.net/manage/user-notes.php?action=edit+25064 http://master.php.net/manage/user-notes.php?action=delete+25064 http://master.php.net/manage/user-notes.php?action=reject+25064

« previous php.notes (#36404) next »