Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
允许用户以JPEG格式下载PHP页面_Php_Image - Fatal编程技术网

允许用户以JPEG格式下载PHP页面

允许用户以JPEG格式下载PHP页面,php,image,Php,Image,我有一个PHP页面,它使用GET参数创建JPEG。我想让用户能够下载该页面的输出为JPEG文件。我该怎么做?非常基本: <?php header('Content-type: image/jpeg'); readfile('cutepuppies.jpg'); 像往常一样从php回显输出,但确保在任何其他输出之前发送一些jpeg的内容类型标题 <?php header("Content-type: image/jpeg"); ?> 设置您的: 至少设置内容类型标题- he

我有一个PHP页面,它使用GET参数创建JPEG。我想让用户能够下载该页面的输出为JPEG文件。我该怎么做?

非常基本:

<?php
header('Content-type: image/jpeg');
readfile('cutepuppies.jpg');

像往常一样从php回显输出,但确保在任何其他输出之前发送一些jpeg的内容类型标题

<?php header("Content-type: image/jpeg"); ?>

设置您的:


至少设置内容类型标题-

header('Content-Type: image/jpeg');
一种方法是利用imagejpeg函数-


你让他们试着按一下
Ctrl+S
?@Charles这很有帮助,非常感谢。你不需要在调用
标题时添加换行符。事实上,它们在现代PHP版本中被积极过滤掉,以帮助减轻标头注入攻击。
header('Content-Type: image/jpeg');