1
我想检查用户是否使用表单上传图像。如何检查文件是否已上传?
我曾尝试:
if (empty($_FILES['txtImage'])) {
$msg = 'Opss, you forgot the image.';
}
我想检查用户是否使用表单上传图像。如何检查文件是否已上传?
我曾尝试:
if (empty($_FILES['txtImage'])) {
$msg = 'Opss, you forgot the image.';
}
自PHP 4.2.0,PHP返回一个适当的错误代码与文件阵列沿。
所以,
<?php
if ($_FILES['txtImage']['error'] === UPLOAD_ERR_NO_FILE) {
$msg .= "Opss, you forgot the image.<br>";
}
?>
http://www.php.net/is_uploaded_file
if(!file_exists($_FILES['myfile']['tmp_name']) || !is_uploaded_file($_FILES['myfile']['tmp_name'])) {
echo 'No upload';
}
,另外,你可以用和getimagesize(检查),如果返回FALSE,它是不是一个图像