If you want to be able to provide the open/save dialog box, Content-Disposition parameter, Content-Disposition The parameter was originally intended to provide a suggested file name when the client saves a file, but for security reasons, this parameter was removed from the specification. Content-Disposition parameters: attachment --- download as attachment inline --- Open online Specific use:
In fact, IE identifies this file type based on the suffix of the file name in the filename section of Content-Disposition. If there are many file types, you can set Content-Type to binary mode: Header("Content-type: application/octet-stream"); Example:
The above code realizes that the download and save window will appear immediately after opening the page, and the downloaded file is $filename. Some commonly used mimetype types: $mimetypes = array( 'doc' => 'application/msword', 'bin' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'so' => 'application/octet-stream', 'dll' => 'application/octet-stream', 'pdf' => 'application/pdf', 'ai' => 'application/postscript', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'dir' => 'application/x-director', 'js' => 'application/x-javascript', 'swf' => 'application/x-shockwave-flash', 'xhtml' => 'application/xhtml+xml', 'xht' => 'application/xhtml+xml', 'zip' => 'application/zip', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mp3' => 'audio/mpeg', 'rm' => 'audio/x-pn-realaudio', 'rpm' => 'audio/x-pn-realaudio-plugin', 'wav' => 'audio/x-wav', 'bmp' => 'image/bmp', 'gif' => 'image/gif', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'png' => 'image/png', 'css' => 'text/css', 'html' => 'text/html', 'htm' => 'text/html', 'txt' => 'text/plain', 'xsl' => 'text/xml', 'xml' => 'text/xml', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'avi' => 'video/x-msvideo', 'movie' => 'video/x-sgi-movie', );>>>> Articles you may be interested in: When downloading the php header function file, you will be prompted to save it directly Easy to use php header download function php get_headers method to detect whether the URL is valid PHP header function usage example php header function usage detailed example (2) php header function usage example (1) Detailed explanation of php header usage php header information application example Examples of php using headers to send various types of files for download Detailed explanation of HEADER header message in PHP |