请参阅下面的代码,我没有收到任何错误,此代码之前有效,我确实改变了一些事情,但我似乎无法找到问题。非常感谢任何帮助。
实际上,代码没有检查文件的格式,它没有检查大小,也没有将文件上传到目录。
if ($_FILES['company_photos_uplaod']['filesToUpload']) {
$Photos = $_FILES['company_photos_uplaod']['name'];
$tmp_n = $_FILES['company_photos_uplaod']['tmp_name'];
$photo_size = $_FILES['company_photos_uplaod']['size'];
$photo_ext = strtolower(pathinfo($Photos, PATHINFO_EXTENSION));
$dir = 'images/'; // upload directory
foreach($_FILES['company_photos_uplaod']['filesToUpload'] as $file) {
if ($photo_ext != "jpg" && $photo_ext != "png" && $photo_ext != "jpeg") {
$response["message"] = 'photos_invalid_format';
$errors++;
}
if ($photo_size > 500000) { //500 Kb max
$response["message"] = 'photos_file_too_large';
$errors++;
}
$new_photo_names = rand(1000, 1000000).
".".$photo_ext;
if ($errors == "") {
if (move_uploaded_file($tmp_n, $dir.$new_photo_names)) {
// upload photos and move to directory folder
} else {
$response["message"] = 'photos_error';
$errors++;
}
}
}
}