我的代码:
if(isset($_FILES['image'])){
$allowedExts = array('jpg', 'gif', 'png');
$extension = end(explode('.', $_FILES['image']['name']));
if(in_array($extension, $allowedExts)){
if($_FILES['image']['size'] < 50000){
if ($_FILES['image']['error'] > 0){
$uploaderror = $_FILES['image']['error'];
}else{
$uploaderror = 'FALLBACK ERROR';
if(file_exists('..images/'.$_FILES['image']['name'])){
$uploaderror = 'The file <strong>'.$_FILES['image']['name'].'</strong> already exists in the images directory.';
}else{
move_uploaded_file($_FILES['file']['tmp_name'], '..images/'.$_FILES['file']['name']);
$uploadsuccess = $_FILES['file']['name'];
}
}
}else{$uploaderror = 'The image is too large.';}
}else{$uploaderror = 'Only images (.jpg, .png, and .gif) are allowed.';}
}else{$uploaderror = 'No attempt';}
输出:
$uploaderror
返回FALLBACK ERROR
且未$uploadsuccess
设置。该文件未出现在指定目录中,我在服务器上找不到它。请告诉我我做错了什么。谢谢!