关于header()中参数问题

来源:1-33 简化文件写入和读取操作

前端小白AAA

2018-07-26 22:51:32

<?php

header('content-type:image/jpeg');

$filename='1.txt';

$filename='king-1.jpg';

$handle=fopen($filename,'rb+');

// var_dump($handle);

$res=fread($handle,filesize($filename));

fclose($handle);

echo $res;

//fopen中打开的图片不管什么格式header()中都写'image/jpeg'吗?

//如果是音乐和视频呢?

写回答

1回答

好帮手慕查理

2018-07-27

您好,JPG、JPEG图片设置header的内容类型为image/jpeg。

header('Content-Type: text/html; charset=utf-8'); //网页编码

header('Content-Type: text/plain'); //纯文本格式

header('Content-Type: image/jpeg'); //JPG、JPEG

header('Content-Type: application/zip'); // ZIP文件

header('Content-Type: application/pdf'); // PDF文件

header('Content-Type: audio/mpeg'); // 音频文件

header('Content-type: text/css'); //css文件

header('Content-type: text/javascript'); //js文件

header('Content-type: application/json'); //json

header('Content-type: application/pdf'); //pdf

header('Content-type: text/xml'); //xml

header('Content-Type: application/x-shockw**e-flash'); //Flash动画

如果解决了您的问题,请采纳。祝学习愉快!

0

0 学习 · 2569 问题

查看课程