请帮助PHP代码:
我有以下代码,只能上传360x514图像。 我的问题是:如何编辑它以使任何大小上传而不会出现错误消息?
<?php
$MAXIMUM_FILESIZE = 5 * 1024 * 1024;
$uploaddir = './uploads/image/large_image/';
$file = $uploaddir . basename($_FILES['image2']['name']);
$raw_file_name= $_FILES['image2']['tmp_name'];
list($width, $height) = getimagesize($_FILES['image2']['tmp_name']);
if ($width==360 && $height==514) {
if (move_uploaded_file($_FILES['image2']['tmp_name'], $file)) {
echo "success";
}
else {
echo "error";
}
}else {
echo "size_error";
}
?>
答案 0 :(得分:5)
像@Musa说的那样,删除支票:
<?php
$uploaddir = './uploads/image/large_image/';
$file = $uploaddir . basename($_FILES['image2']['name']);
$raw_file_name = $_FILES['image2']['tmp_name'];
if (move_uploaded_file($_FILES['image2']['tmp_name'], $file)) {
echo "success";
} else {
echo "error";
}
答案 1 :(得分:1)
list($width, $height) = getimagesize($_FILES['image2']['tmp_name']);
if ($width==360 && $height==514) {
if (move_uploaded_file($_FILES['image2']['tmp_name'], $file)) {
echo "success";
}
else {
echo "error";
}
如果你阅读它,它就在你的代码中......这里它说它必须等于360x514,只需要去掉那个IF语句,然后跳到move_uploaded_file命令。