警告:move_uploaded_file(/images/24_silver_2_1.jpg):无法打开 stream:没有这样的文件或目录 C:\ Inetpub \ vhosts \ leojungen.com \ httpdocs \ launch-complaint.php在线 72
警告:move_uploaded_file():无法移动 'C:\ Windows \ Temp \ php19A2.tmp'到'/images/24_silver_2_1.jpg'in C:\ Inetpub \ vhosts \ leojungen.com \ httpdocs \ launch-complaint.php在线 72
function uploadMultipleFiles($complaintId){
global $_pdo;$path = '';
// Count # of uploaded files in array
$total = count($_FILES['files']['name']);
// Loop through each file
for($i=0; $i<$total; $i++) {
//Get the temp file path
$tmpFilePath = $_FILES['files']['tmp_name'][$i];
//Make sure we have a filepath
if ($tmpFilePath != ""){
//Setup our new file path
$newFilePath = "/images/".$complaintId."_".$_FILES['files']['name'][$i];
//Upload the file into the temp dir
//echo "path: "; print_r($_SERVER);exit;
move_uploaded_file($tmpFilePath,$newFilePath);
}
$path .= $complaintId."_".$_FILES['files']['name'][$i]."^";
}
}
在我的本地环境中,一切都是工作文件,但是当我在现场部署它时,它无法正常工作。
答案 0 :(得分:2)
这是因为服务器上没有目录/images
,或者缺少该目录上的write permission
。检查并修复此问题,然后重试。
答案 1 :(得分:1)
$newFilePath = "/images/".$complaintId."_".$_FILES['files']['name'][$i];
将此更改为
$newFilePath = "images/".$complaintId."_".$_FILES['files']['name'][$i];
答案 2 :(得分:0)
代替: $ newFilePath =&#34; / images /&#34;。$ complaintId。&#34; _&#34;。$ _ FILES [&#39; files&#39;] [&#39; name&#39;] [ $ I];
请尝试以下方法:
$ newFilePath =&#34; ./ images&#34;。$ complaintId。&#34; _&#34;。$ _ FILES [&#39; files&#39;] [&#39; name&#39; ] [$ i]于;
./images中的句号表示root / images ....如果root和images之间还有其他...包含它我知道这是一个非常古老的问题,但我发布了这个答案,以便如果像我这样的任何新编码器......他会得到适合我的解决方案