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.
精彩评论