Online! If you have any questions about uploading files, please help the girl ~ -Php Tutorial

Source: Internet
Author: User
Online help! A question about downloading files. could you help the girl ~~ & Lt ;? Success; $ file_dir & nbsp; $ title & nbsp; & 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); [email protected]
}
?>

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 ().

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.