简体   繁体   中英

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);`

Here is my code to download an audio file. It was successful and the file is saved to system downloads folder. Now I want to have an application specific download folder and save all downloaded music files to that folder only so that I can use directory listing to show all those downloads.

I tried coding like:

rename('C:\Users\user2\Downloads/'.$file,
       'C:\Users\user2\Music\Playlists/'.$file);

But it's not working all the time. Any Help is Appreciated.

如图所示,修改您的代码,因为您在Windows计算机上工作,请更改斜杠

rename("C:\Users\user2\Downloads\$file", "C:\Users\user2\Music\Playlists\$file");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM