【发布时间】:2019-06-22 01:40:27
【问题描述】:
我正在尝试通过 alamofire 上传图片,我已经做到了!我的服务器收到了它,但是当我在我的 php 文件中调用 move_uploaded_file 函数时,它显示失败。我确信我的服务器收到了图像,并且我能够通过 php 创建目录。只是这个 move_uploaded_file 不让我做这项工作。这是我的php代码:
<?php
if (empty($_FILES["image"])){
$response = array("error" => "no data");
}else{
$path = "./Upload";
if(!file_exists($path)){
mkdir($path,0777,true);
$response["message"] = "new file created";
}else{
$response["message"] = "file already exist";
if(move_uploaded_file($_FILES["image"]["tmp_name"],$path)){
$response["message"] = "You've got it!!!";
}else{
$response["message"] = "upload function fail";
}
}
}
echo json_encode($response);
?>
【问题讨论】:
-
$path 是目录,不是文件