Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I use this script when user request mp3 file to download it from local server:
----------------------------------------------------------Code: Select all
$download="aaaa.mp3";
$mm_type="application/octet-stream";
header("Cache-Control: public, must-revalidate");
header("Pragma: hack");
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)filesize($download) );
header('Content-Disposition: attachment; filename="'.basename($download).'"');
header("Content-Transfer-Encoding: binary\n");
$fp = fopen($download, 'rb');
$buffer = fread($fp, filesize($download));
fclose ($fp);
print $buffer;but my problem is to do the same thing for letting my users downloading my files that exist in another server (mine server too):
I used this but failed:
-----------------------------------------------------------------------
Code: Select all
$connid=ftp_connect("my remote server");
$logresult=ftp_login($connid,"user","psw");
if ((!$connid) || (!$logresult)) {
echo "FTP connection has failed!";
exit;
}
else {
$file = "/files/aaa.mp3";
$download_size = ftp_size($connid, $file);
}
header("Cache-Control: public, must-revalidate");
header("Pragma: hack");
header("Content-Type: " . $mm_type);
header("Content-Length: " .$download_size);
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header("Content-Transfer-Encoding: binary\n");
$fp = fopen($file, 'rb');
$buffer = fread($fp, $download_size);
fclose ($fp);
ftp_close($connid);
print $buffer;please advise me how to do that
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]