Home >Operation and Maintenance >Nginx >How to configure the specified save file name for file download in nginx
Generally after we upload the resource file, in order to avoid file name conflicts, the file name will be changed to a meaningless period of characters. This character may be generated by md5, or a string generated by other methods. At this time, when downloading, the file name saved by default will be this meaningless file name (Figure 1).
In fact, nginx supports renaming during downloading, making the file name more friendly.
nginx is also easy to configure: just add the following lines:
Copy code The code is as follows:
location ~* . *\.(doc|txt|jar|zip|apk)(\?.*)?$
{
If ($request_uri ~* ^.*\/(.*)\.(doc|txt |jar|zip|apk)(\?n=([^&] ))$) {
add_header content-disposition "attachment;filename=$arg_n.$2";
expires 30d;
break;
}
The above is the detailed content of How to configure the specified save file name for file download in nginx. For more information, please follow other related articles on the PHP Chinese website!