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

时间:2014-11-30 15:25:13

标签: php ios image upload

 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;

数据未通过设备上传。当我从桌面填写表单但不通过iPhone填写表单时可以使用。

创建路径但不是数据

1 个答案:

答案 0 :(得分:0)

您是否尝试过让设备独立? 即删除此代码:

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