使用Postman通过HTTP POST上传图像 [英] Upload an image through HTTP POST with Postman
问题描述
我一直在尝试将邮件通过Postman发送到一个简单的PHP脚本,该脚本应显示发送的图像。我遵循的步骤是:
邮递员客户端端:
- 选择 POST 请求
- 选择值为 multipart / form-data 的HEADER Content-Type
- 在正文选项卡中,选择 form-data 引入 key = image_test,从 Text 更改为 File 并搜索图片,例如:photo.png
- 发送POST请求。
在PHP脚本中,我只有:
echo'< img src = data:multipart / form-data,'。$ _POST ['image_test']。' / >';
尽管使用 print_r($ _ POST)$,此解决方案对我不起作用c $ c>我能够看到编码的图像。可能是主机( https://ide.c9.io )或邮递员的问题吗?我还对Postman和base64图片进行了一些其他测试,而Postman的 Display 标签无法显示解码的图片;唯一的方法是通过浏览器进行访问。
某些代码将有助于了解您要执行的操作。您可以尝试将图像以base64编码发送回客户端。有关示例,请参见如何将图像转换为base64编码? / p>
I've been trying for a while to send an image via Postman to a simple PHP script that should display the sent image. The steps I followed were:
Postman "client" side:
- Select POST request
- Select HEADER Content-Type with value multipart/form-data
- In the Body tab select form-data introduce the key = image_test, change from Text to File and search for a image, ex: photo.png
- Send POST request.
In the PHP script I just have:
echo '<img src="data:multipart/form-data,' . $_POST['image_test'] .'"/>';
This solution isn't working for me although with print_r($_POST)
I'm able to see the encoded image. Could this be a problem of the host (https://ide.c9.io) or Postman? I made some other tests with Postman and base64 images and the Display tab of Postman wasn't able to display the decoded images; the only way was to access through the browser.
Some code would help to understand what you are trying to do. You could try to send the image back to the client in base64 encoding. See How to convert an image to base64 encoding? for an example
这篇关于使用Postman通过HTTP POST上传图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!