Online! If you have any questions about uploading files, please help the girl ~
Source: Internet
Author: User
Online help! A question about downloading files. could you help the girl ~~ & Lt ;? Php $ file_name & nbsp ;=& nbsp; 'http: // 5.66825.com/download/ring/000/102/0b6983e56159d5e830936096e27b247 online help! A question about downloading files. could you help the girl ~~
$ File_name = 'http: // response ';
$ File_dir = '';
$ Title = 'download ringtones ';
$ Title = str_replace ('\ '','', $ title );
$ Rename = 'rename' .'_'.{title ';
If (! File_exists ($ file_dir. $ file_name) {// check whether the file exists
Echo" File does not exist ";
Exit;
} Else {
// Below is the focus of PHP file download
Header ("Content-type: application/octet-stream ");
Header ("Accept-Ranges: bytes ");
Header ("Content-Type: application/force-download"); // force the browser to download
Header ("Content-Disposition: attachment; filename = \" ". $ rename." \ ""); // rename the file
Header ("Accept-Length:". filesize ($ file_dir. $ file_name); // file size
// Read the file content
@ Readfile ($ file_dir. $ file_name); // add @ no error message output
}
?>
The problem I have now is that I want to download a remote mp3 file through the file in the code above, but it always fails and always prompts that the file does not exist.
However, if I delete the if judgment, it can be downloaded, but the downloaded files are all bad (not the actual path file)
------ Solution --------------------
Your code is feasible. remove the if judgment section. Wait until it is finished.
------ Solution --------------------
Filesize does not support remote file Detection. only one function is file_get_contents ().
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.