简体   繁体   English

多个图像应从iPhone上传到php服务器

[英]multiple images should be uploaded from iphone to a php server

multiple images should be uploaded from iphone to a php server and images will be sent to php server as an http request. 多个图像应从iphone上传到php服务器,并且图像将作为http请求发送到php服务器。

something like this www.ursite.com/event_id=1234qwer&method=upload&data=!@#$%^&*&^%$#@!!.... 像这样的东西www.ursite.com/event_id=1234qwer&method=upload&data =!@#$%^&*&^%$#@ !! ....

data=!@#$%^&&^%$#@!!&&(&&$$%$@$@GFGF%$4.... data =!@#$%^ && ^%$#@ !! &&(&& $$%$ @ $ @ GFGF%$ 4 ....

it would a random value and it is packet of data[images]. 它将是一个随机值,并且是数据包[图像]。 We need to read this raw data using php 我们需要使用php读取原始数据

how can I do that?? 我怎样才能做到这一点??

http://pastebin.com/WAp5AV5Y http://pastebin.com/WAp5AV5Y

You shouldn't be sending your data as a GET request, you should be sending it as a multipart POST call. 您不应该将数据作为GET请求发送,而应该将其作为多部分POST调用发送。 There's plenty of resources about that over the web, SO included. 网络上有很多资源,包括SO。 Also check out this page . 请查看此页面

On the PHP side you will receive the uploaded files in the $_FILES array just as if the user uploaded the images from a HTML form so you don't need to do anything special to handle an iPhone upload. 在PHP端,您将收到$ _FILES数组中的已上传文件,就像用户从HTML表单中上传图像一样,因此您无需执行任何特殊操作即可处理iPhone上传。

I have some good news, and I have some bad news. 我有一些好消息,也有一些坏消息。

The good news is that the image data is just a JPEG, so GD's imagecreatefromstring will do the job nicely to ensure that the data is a valid image. 好消息是,图像数据只是JPEG,因此GD的imagecreatefromstring将很好地完成此工作,以确保数据是有效的图像。

The bad news is twofold: 坏消息是双重的:

  1. The data has come in without the benefit of URL-encoding, so it is surely corrupt. 数据输入没有URL编码的好处,因此它肯定已损坏。
  2. GET method requests have a relatively small available data size. GET方法请求具有相对较小的可用数据大小。

You will need to have the data submitted as a POST, properly encoded. 您将需要以正确的编码将数据提交为POST。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM