Both ASP and PHP can customize header parameters, which are rarely used, but they are still very useful. Here we will summarize them.
UsageArticleTake ASP as an example:
ASP:
<%
Response. contenttype = "for details about contenttype settings, see"
Response. addheader "name", "value"
%>
PHP:
<%
Header ("Content-Type: contenttype setting can be found below ");
Header ("Name: Value ");
%>
Application:
1. Force download. Some file formats are opened by default in the browser, such as DOC files and Excel files. If you have installed office, it will be opened directly in the browser. More than a single file, PDF file. Sometimes, we hope it can be saved directly, especially for some download sections. At this time, you only need to add a header parameter:
<% Response. addheader "content-disposition", "attachment" %>
The download window is automatically opened.
2. Hide the file name. Sometimes, we do not want to tell others the file name, or even we do not have a file name, because many times the content is dynamically generated and there is no good file name, which is confusing to users, they have to change their names. At this time, we can add another value.
<% Response. addheader "content-disposition", "attachment; filename = file name you need to get" %>
PS: when calling the preceding statement, add the previous statement to set the document category.
Content-Type is in the form of "primary type/subtype. Main types include text, image, audio, video,
Application, multipart,
Message, indicating text, images, audio, video, application, segmentation, messages, etc. Each primary type may have multiple child types, for example, the text type contains plain,
HTML, XML,
CSS. The primary and subtypes starting with X-also indicate custom types. They are not officially registered with iana, but most of them have been agreed to be vulgar. For example, application/X-
Zip-compressed is a zip file. In Windows, the Registry's "hkey_classes_root \ mime \ database \
Content type lists most known content-types except multipart.
There are many supplementary provisions in the RFC regarding the form of parameters. Some may include several parameters.
Primary Type |
Parameter Name |
Description |
The character set can also be seen in "hkey_classes_root \ mime \ database \ charset" in the Windows registry.
For example:
Excel: Application/vnd. ms_excel
Word: Application/MSWord
Image: image/GIF
HTML: text/html
I found it messy after writing it ...... I don't know whether I understand it or not. I just want to leave a message for me ......