开发者

Download with different name

开发者 https://www.devze.com 2023-01-28 16:17 出处:网络
I\'m setting up a script tha开发者_JAVA百科t\'ll download files from a URL with wget and make them available for download. I\'d like to save them each with unique ID numbers, however the downloaded fi

I'm setting up a script tha开发者_JAVA百科t'll download files from a URL with wget and make them available for download. I'd like to save them each with unique ID numbers, however the downloaded file must be called something different. How can I initiate a download of a file with a different name than is stored on the server?

Many thanks in advance.


You can use header

header('Content-Disposition: attachment; filename="downloaded.pdf"');
readfile("/path/to/file");


You can also have a counter that counts the number of files you are downloading and after you download each one you can rename the file name to xxxx1.dat, then you'll have xxxx2.dat, etc. That will also allow you to know the order of the files, if that is of some interest to you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号