我有这段代码:
$name="dsds"
if(isset($_FILES))
{
$imagename = $_FILES['uploadimage'].$name;
$imagetype = $_FILES['uploadimage'].$type;
$imagesize = $_FILES['uploadimage'].$size;
if($imagetype != "image/gif" || $imagetype != "image/jpg" || $imagetype == "image/png" || $imagetype == "image/jpeg")
{
$error = 'Please upload an image with JPG, PNG, GIF';
}
elseif($imagesize > 716800)
{
$error = 'Image Needs to be under 700kb only';
}
else
{
$success = 'Uploaded';
}
但有时会上传图像,但会在文件名中添加“数组”,有时它根本不起作用。
答案 0 :(得分:3)
发现你的错误。我想你的意思是
$imagename = $_FILES['uploadimage']['name'];
而不是
$imagename = $_FILES['uploadimage'].$name;
答案 1 :(得分:1)
$imagename = $_FILES['uploadimage']['name'];
$imagetype = $_FILES['uploadimage']['type'];
$imagesize = $_FILES['uploadimage']['size'];
您必须像这样使用它,name
,type
和size
不是变量而是键