没有' tmp_name'通过php

时间:2017-04-28 12:13:46

标签: php xml encoding

我对PHP比较陌生,我正在创建数据库报告的上传页面。这些报告会自动显示为utf-16个XML页面,并且在创建时无法转换为utf-8。该报告附带摘要页面和报告页面,然后存档并提交。唯一的问题是每个文件上传 - 除了zip中的utf-16编码文件。 zip文件似乎没有设置为tmp_name,但如果文件是utf-8或任何其他文件,则会执行此操作。  我的代码如下:

$newfiles = array_filter($_FILES['userfile']['name']);
$count= count($_FILES['userfile']['tmp_name']);
echo $count
for($i=0; $i<$count; $i++) {
//Setup a temp filepath
 $tmpFilePath = $_FILES['userfile']['tmp_name'][$i];
  echo 'temp file path is set as ' . $tmpFilePath;
 //Make sure we have a filepath
 if ($tmpFilePath != ""){
 //Setup our new file path
 $destination_path = getcwd().'/ddr/';
 $target_path = $destination_path . basename( $_FILES['userfile'].    ['name'][$i]);

 //echo "hello";
 if (move_uploaded_file($tmpFilePath, $target_path)) {
    echo "The file ". basename( $_FILES["userfile"]["name"] [$i]). "    has been uploaded to " . $target_path;
} else {
    echo "Sorry, there was an error uploading your file to " .   $target_path;
}
$uploadfiletype = pathinfo($target_file,PATHINFO_EXTENSION);
 if ($uploadfiletype = '.zip'){
  $zip = new ZipArchive;
  $res = $zip->open($target_path);
  if ($res === TRUE) {
    $zip->extractTo($destination_path);
    $zip->close();
    //echo 'ok';
    } else {
    echo 'failed';
    }
  } 
 }
}

我的echo 'temp file path is set as ' . $tmpFilePath;只返回$tmpfilepath值,但echo $count;确实返回了值。有什么想法吗?

提前致谢

编辑:它与最大上传大小无关

0 个答案:

没有答案