如何限制图片大小 我在哪里插入代码? 我可以设法上传图片,但它只能上传和显示4张图片。 我能做些什么来解决它?
答案 0 :(得分:0)
使用PHP上传文件时,上传时可用的信息在数组中:$ _FILES ['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]会以字节为单位给出filesize。如果你想根据它的尺寸处理上传,你必须先完成上传,然后使用PHP函数检查尺寸:getimagesize