我有一个将文本和图像上载到服务器/数据库的表单,除我使用file_exists
之外,其他所有条件均适用。
这是怎么了?
if(isset($_FILES["tipimage"]) && $_FILES["tipimage"]["error"] == 0){
$allowed = array("jpg" => "image/jpg", "jpeg" => "image/jpeg", "gif" => "image/gif", "png" => "image/png");
$filename = $_FILES["tipimage"]["name"];
$filetype = $_FILES["tipimage"]["type"];
$targetDir = "uploads/";
$targetFilePath = $targetDir . $filename;
// Verify file extension
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if(!array_key_exists($ext, $allowed)) {
$error .= "Invalid File Format<br>";
}
}
if(file_exists("upload/" . $_FILES["tipimage"]["name"])){
$error .= "File" . $_FILES["tipimage"]["name"] . " already exists.<br>";
}
else if (move_uploaded_file($_FILES["tipimage"]["tmp_name"], $targetFilePath)){
$successmsg .= "<div class='alert alert-success'>Image - " . $filename . " Uploaded Successfully!</div>";
}
if($error) {
$dangererror = "<div class='alert alert-danger'>";
$dangererror .= $error;
$dangererror .= "</div>";
}
答案 0 :(得分:0)
这是由于一个简单的错字。
我的变量设置为“上传”
library(dplyr)
library(ggplot2)
mtcars %>%
ggplot(aes(am, wt, group = am, label = wt)) +
geom_boxplot(outlier.shape = NA) +
geom_jitter(position = position_jitter(seed = 1)) +
geom_text(position = position_jitter(seed = 1))
在我写的if语句中,“ upload”是正确的路径
$targetDir = "uploads/";