2011-07-13 50 views
0

如何限制图片大小 以及我在哪里插入代码? 我可以设法上传图片,但它只能上传和显示4张图片。 我能做些什么来解决它?如何限制图片上传大小php

+0

您需要显示一些您的代码。 –

+0

你是什么意思的大小?尺寸还是千字节? – tvgemert

回答

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) 

[大小]会给你以字节文件大小。如果您想根据尺寸处理上传,您必须先完成上传,然后使用PHP函数检查尺寸:getimagesize