[英]Rename function to move a file between folders does not work properly
header ("Content-type: octet/stream");
header ("Content-disposition: attachment; filename=".$file.";");
header("Content-Length: ".filesize($file));
readfile($file);`
這是我下載音頻文件的代碼。 成功,文件被保存到系統下載文件夾中。 現在,我想擁有一個特定於應用程序的下載文件夾,並將所有下載的音樂文件僅保存到該文件夾,以便我可以使用目錄列表顯示所有這些下載。
我試過像這樣編碼:
rename('C:\Users\user2\Downloads/'.$file,
'C:\Users\user2\Music\Playlists/'.$file);
但這並不是一直都在工作。 任何幫助表示贊賞。
如圖所示,修改您的代碼,因為您在Windows計算機上工作,請更改斜杠
rename("C:\Users\user2\Downloads\$file", "C:\Users\user2\Music\Playlists\$file");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.