在iPhone上通过handycamera上传文件的问题

时间:2019-06-18 14:08:47

标签: php html iphone file-upload input-field

我正在尝试通过handycamera和文件Input上传照片。它可以在Android上使用,但是当我在Iphone上尝试使用时,似乎只是正在加载...。但是文件从未上传过。

<input type="file" id="fileToUpload" accept="image/*" name="fileToUpload[]" onchange="changeFile()" style="width: 0; height: 0; overflow: hidden;" multiple>


$startUpload = true;
$target_dir = "./tmp/";
$names = array( 'name' => 1, 'type' => 1, 'tmp_name' => 1, 'error' => 1, 'size' => 1);
foreach ($_FILES['fileToUpload'] as $key => $part) {
    $key = (string) $key;
    if (isset($names[$key]) && is_array($part)) {
        foreach ($part as $position => $value) {
            $_FILES['fileToUpload'][$position][$key] = $value;
        }
        unset($_FILES['fileToUpload'][$key]);
    }
}
$time = round(microtime(true) * 1000);
foreach ($_FILES['fileToUpload'] as $key => $value) {
  $time++;

  //$target_file = $target_dir . $_SESSION['userId'] . "_" . basename($value["name"]) ;
  $target_file = $target_dir . $_SESSION['userId'] . "_" . $time;
  $imageFileType = strtolower(pathinfo($value["name"],PATHINFO_EXTENSION));
  $target_file = $target_file . "." . $imageFileType;

  $check = getimagesize($value['tmp_name']);
  if($check !== false){
    // echo "Image - " . $check['mime'] . ".";
    $uploadOk = true;
  }else {
    // echo "Not Image.";
    $uploadOk = false;
  }

  if(file_exists($target_file)) {
    $uploadOk = false;
  }

  if($uploadOk == false){
    $uploadFailed = true;
  } else {
    if(move_uploaded_file($value['tmp_name'], $target_file)) {
      // some code;
    } else {
      // some code;
    }
  }
}

这是我的输入字段,以及我如何上传文件,有人可以帮忙吗?

提前谢谢!

0 个答案:

没有答案