I'm writing a web application that, among other things, allows users to upload files to my server. In order to prevent name clashes and to organize the files, I rename them once they are put on my server. By keeping track of the original file name I can communicate with the file's owner without them ever knowing I changed the file name on the back end. That is, until they go do download the file. In that case they're prompted to download a file with a unfamiliar name.
My question is, is there any way to specify the name of a file to be downloaded using just HTML? So a user uploads a file named 'abc.txt' and I rename it to 'xyz.txt', but when they download it I want the browser to save the file as 'abc.txt' by default. If this isn't possible with just HTML, is there any way to do it?
There are many ways to rename a file in Windows. The easiest way is by right-clicking on the file and selecting Rename. You can then type a new name for your file and press enter to finish renaming it. A quicker way to rename a file is by first selecting it by left clicking on it, then pressing the F2 key.
Note: If your address bar is at the bottom, swipe up on the address bar. Tap Downloads. Step 5: From the given option tap Rename. Step 6: Enter your new file name.
Each time a file is added to the Downloads folder, this action will run, and it will automatically rename files with names containing "%20" to use spaces instead.
When they click a button to download the file, you can add the HTML5 attribute download
where you can set the default filename.
That's what I did, when I created a xlsx file and the browser want to save it as zip file.
<a href="path/to/file" download="renamed.txt">Download</a> <a href="downloads/export.xlsx" download="Data-Export.xlsx">Download Export</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With