2

我有这个代码:

$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';
                        }

但有时它会上传图像,但会在文件名中添加“Array”,有时它根本不起作用。

4

2 回答 2

3

发现你的错误。我想你的意思是

$imagename = $_FILES['uploadimage']['name'];

并不是

$imagename = $_FILES['uploadimage'].$name;
于 2013-08-29T17:49:32.913 回答
1
$imagename = $_FILES['uploadimage']['name'];
$imagetype = $_FILES['uploadimage']['type'];
$imagesize = $_FILES['uploadimage']['size'];

您必须像这样使用它,,name不是变量而是键typesize

于 2013-09-05T07:23:36.963 回答