简体   繁体   English

尝试使用PHP将图像从iPhone上传到服务器

[英]Trying to upload image from iPhone to server with PHP

 if ($_REQUEST['device_type'] == '1') {

       $fileName = $_FILES['media_chunk']['name'];
        $tmpName = $_FILES['media_chunk']['tmp_name'];
        //$fileSize = $_FILES['imageData']['size'];
       //$fileType = $_FILES['imageData']['type'];

        $fp = fopen($tmpName, 'r');
        $content = fread($fp, filesize($tmpName));
        $content1 = addslashes($content);
        fclose($fp);

         $file_name = $db->host . 'snaps/' . $_REQUEST['media_name']; // . $owner_id

         $file_to_open = 'snaps/' . $_REQUEST['media_name'];

        $handle = fopen($file_to_open, 'a');
        fwrite($handle, $content);
        fclose($handle);

        $msg = new getErrorMsg('0');
        $json = array('FilePath' => $file_name, 'statusMessage' => $msg->errMsg, 'statusNumber' => $msg->errNo);
        echo json_encode($json);
        return false;

The data isn't being uploaded through device. 数据未通过设备上传。 Works when I fill out form from desktop but not through iPhone. 当我从台式机而不是通过iPhone填写表格时可以使用。

Path is created however just not the data 创建路径,但是不创建数据

Have you tried making it device independent? 您是否尝试过使其独立于设备? ie by removing this code: 即通过删除此代码:

 if ($_REQUEST['device_type'] == '1') {

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

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