Tags
Asked 1 years ago
28 Feb 2023
Views 356
sarah

sarah posted

List of Content-Type of header() function for differ file format

List of Content-Type of header() function for differ file format

header('Content-Type: ----');
steave ray

steave ray
answered Feb 28 '23 00:00

Here are some common Content-Type values for different file formats that can be used with the header() function in PHP:

text/plain : Plain text files (e.g., .txt , .log , .csv )
text/html : HTML files (e.g., .html , .htm )
application/json : JSON data (e.g., .json )
application/pdf : PDF files (e.g., .pdf )
application/zip : ZIP archives (e.g., .zip )
application/vnd.ms-excel : Microsoft Excel files (e.g., .xls , .xlsx )
application/msword : Microsoft Word files (e.g., .doc , .docx )
application/vnd.openxmlformats-officedocument.wordprocessingml.document : Microsoft Word files (e.g., .docx )
image/jpeg : JPEG images (e.g., .jpg , .jpeg )
image/png : PNG images (e.g., .png )
image/gif : GIF images (e.g., .gif )
video/mp4 : MP4 videos (e.g., .mp4 )
text/plain: PHP file (e.g., .php )


Note that this is not an exhaustive list, and there may be other Content-Type values that are appropriate for specific file formats. You can also use the mime_content_type() function in PHP to automatically detect the appropriate Content-Type value based on the file extension .
Post Answer