聘我网

新概念招聘3.0

问一个关于php文件上传的问题

vote up0vote downstar

上传一些TXT文件和图片的php方法,没有问题。但是不知道,如果我要上传mp3或者视频之类的东西,这种东西的php方法该怎么写啊。那位高手帮帮忙啊,写一个出来看下3Q

 

2 个答复

vote up1vote down

php.ini中需要设置upload_max_filesizepost_max_size足够大才行,其他都是一样的。

另外重要的两点是:

  1. enctype="multipart/form-data"
  2. method="POST"

The "get" method restricts form data set values to ASCII characters. Only the "post" method (with enctype="multipart/form-data") is specified to cover the entire [ISO10646] character set.

参考资料

更新

当上传文件大小超过php.ini规定尺寸时,$_FILES['file']['size']会变成0,

http://cn2.php.net/manual/en/features.file-upload.post-method.php

You can, for example, use the $_FILES['userfile']['size'] variable to throw away any files that are either too small or too big. You could use the $_FILES['userfile']['type'] variable to throw away any files that didn't match a certain type criteria, but use this only as first of a series of checks, because this value is completely under the control of the client and not checked on the PHP side.

链接
vote up0vote down

应该是一样的吧?

链接

您的回答





不是您要找的问题? 浏览其他含有标签 的问题或者 自己问个.