Online Help! A download file problem, we help the little girl ah ah ah ~ ~
$file _name = ' Http://5.66825.com/download/ring/000/102/0b6983e56159d5e830936096e27b2479.mp3 ';
$file _dir = ";
$title = ' downloaded ringtones ';
$title =str_replace (' \ ', ' ', $title);
$rename = ' rename '. ' _ '. $title. ' MP3 ';
if (!file_exists ($file _dir. $file _name)) {//check if file exists
echo " File does not exist ";
Exit
} else {
Here is the key to php file download
Header ("Content-type:application/octet-stream");
Header ("Accept-ranges:bytes");
Header ("Content-type:application/force-download");//Force browser download
Header ("content-disposition:attachment; Filename=\ "". $rename. " \ "");//rename file
Header ("Accept-length:". FileSize ($file _dir. $file _name));//File size
Read File contents
@readfile ($file _dir. $file _name); [Email protected]
}
?>
My problem now is that I want to download the remote MP3 file from the file above, but always fail, always prompt for the file does not exist.
But if I make a decision, it can be downloaded, but the downloaded file is bad (not the actual path file)
------Solution--------------------
Your code works, and if you judge that segment to be removed. Wait for it to finish.
------Solution--------------------
FileSize does not support detecting remote files, a function file_get_contents () can