線上!一個上傳檔案的有關問題,大家幫上小女子呀呀呀呀~

來源:互聯網
上載者:User
線上求助!一個下載檔案的問題,大家幫下小女子呀呀呀呀~~
$file_name = 'http://5.66825.com/download/ring/000/102/0b6983e56159d5e830936096e27b2479.mp3';
$file_dir = '';
$title = '下載的鈴聲';
$title =str_replace('\'','',$title);

$rename = '重新命名'.'_'.$title.'.mp3';
if (!file_exists($file_dir . $file_name)) { //檢查檔案是否存在
echo "檔案不存在";
exit;
} else {
// 一下是php檔案下載的重點
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
Header("Content-Type: application/force-download");//強制瀏覽器下載
Header("Content-Disposition: attachment; filename=\"".$rename."\"");//重新命名檔案
Header("Accept-Length: ".filesize($file_dir . $file_name));//檔案大小
// 讀取檔案內容
@readfile($file_dir.$file_name);[email protected]
}
?>

我現在問題是,想通過上面代碼的檔案下載遠端mp3檔案,但是總是失敗,總是提示檔案不存在。
但是我如果把if判斷去掉,它可以下載,但是下載的檔案都是壞的(不是實質的路徑檔案)


------解決方案--------------------
你的代碼可行,將if判斷那段去掉。等它下完。
------解決方案--------------------
filesize 不支援檢測遠程檔案,一個函數 file_get_contents() 即可
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.