dongzheng7165 2013-06-09 14:12
浏览 14

如何在已设置不同标头时创建图像(对于JSON响应)

I am writing a simple PHP file to upload a file on POST, and to also create a new image and include the path to that new image in the response.

For the JSON response I have set headers in the main PHP file that the POST is sent to - like so:

    header("Content-Type: application/json");

Just before my JSON encoded echo this is.

Above that part I call a function from another PHP file that uploads the POST file, and one that is called after that rendering a different image using that uploaded file.

In that function in order to create the PNG file I need put on the disc I have to declare a new header right? Like so:

header("Content-type: image/png");

I then ofc get the doublet header problem.

How can I get around this problem?

I cannot use header_remove() BTW.

  • 写回答

2条回答 默认 最新

  • douqiao5543 2013-06-09 14:15
    关注

    "In that function in order to create the PNG file I need put on the disc I have to declare a new header right?"

    No.

    Headers should only be sent to browsers. You don't need to send a header to write to disc.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度