Heim  >  Artikel  >  Backend-Entwicklung  >  thinkphp 接收不到ios端post过来的图片,只能接受文字!求大神解答

thinkphp 接收不到ios端post过来的图片,只能接受文字!求大神解答

WBOY
WBOYOriginal
2016-06-06 20:16:181387Durchsuche

<code> $upload = new \Think\Upload();// 实例化上传类    
         $upload->maxSize   =     3145728 ;// 设置附件上传大小
         $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 
         $upload->savePath  =      '/Public/Uploads/images/';
         $info   =   $upload->upload();
         if(!$info) {// 上传错误提示错误信息
             $this->error($upload->getError());
         }</code>

我现在怎么写才能知道 他到底图片post过来了没有呢?

回复内容:

<code> $upload = new \Think\Upload();// 实例化上传类    
         $upload->maxSize   =     3145728 ;// 设置附件上传大小
         $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 
         $upload->savePath  =      '/Public/Uploads/images/';
         $info   =   $upload->upload();
         if(!$info) {// 上传错误提示错误信息
             $this->error($upload->getError());
         }</code>

我现在怎么写才能知道 他到底图片post过来了没有呢?

这个问题你需要跟iOS沟通下,如果对方发原生的NSData,应该是16进制类似这样:

<code><ffd8ffe0></ffd8ffe0></code>

那可以让他用下base64,然后发过来,你就当成字符串接收,然后字符串操作掐头去尾留下16进制内容,再将内容用内置函数转换成二进制,最后用写文件函数将二进制流存为图片。

当然如果iOS可以用第三方直接发二进制,那皆大欢喜(-.-;)

沟通最要紧!!!

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn