Home  >  Article  >  Backend Development  >  用header和imagejpeg配合输出图像的问题

用header和imagejpeg配合输出图像的问题

WBOY
WBOYOriginal
2016-06-23 13:34:131075browse

header('Content-type: image/jpeg')和imagejpeg($img)可以输出图像,但没办法同时输出其他内容,比如一段,

如果用imagejpeg($img, '路径'),先保存图像再输出要刷新网页。

有什么办法可以实现:在同一个网页,用表单输入参数,用GD2制作一个图像,再输出图像在这个页面,保留html的内容,不要刷新。


本人新手,可能问题水平比较低,各位海涵。


回复讨论(解决方案)

imagejpeg($img, '路径');
echo '用header和imagejpeg配合输出图像的问题';
这样试试

将你需要输出的图片单独封装,路径可以为http://www.example.com/action/method/

需要同时输出的html 中加入image标签显示,

<html><head></head><body>...<img  src="http://www.example.com/action/method/" alt="用header和imagejpeg配合输出图像的问题" >...</body></html>

貌似只能封装了,二楼的方法要刷新才能显示由当前页面输入数据所制成的图表。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn