如何限制图片大小以及在哪里插入代码?我可以上传图片,但它只能上传和显示 4 张图片。我能做些什么来解决它?
问问题
212 次
1 回答
0
当您使用 PHP 上传文件时,上传时可用的信息在数组中:$_FILES['image'](image 是表单中输入的文件的名称)。该数组包含一些有用的信息:(复制自: http: //php.net/manual/en/reserved.variables.files.php)
[name] => MyFile.txt (comes from the browser, so treat as tainted)
[type] => text/plain (not sure where it gets this from - assume the browser, so treat as tainted)
[tmp_name] => /tmp/php/php1h4j1o (could be anywhere on your system, depending on your config settings, but the user has no control, so this isn't tainted)
[error] => UPLOAD_ERR_OK (= 0)
[size] => 123 (the size in bytes)
[size] 将为您提供以字节为单位的文件大小。如果要根据其尺寸处理上传,则必须先完成上传,然后使用 PHP 函数检查尺寸:getimagesize
于 2011-07-13T07:54:29.250 回答