php中的$_FILES

WBOY
Release: 2016-06-23 13:22:23
Original
1184 people have browsed it

php中的文件上传的内容存储在$_FILES全局变量里,$_FILES[$name][$key]。要用到文件上传,HTML表单中的form标签的属性里要加“enctype=multipart/form-data”,且表单上传只能用post方式。$_FILES里存储的形式(假设表单中的上传文件中的input里的name=pic):Array('pic'=>Array('name'=>'test.jpg','type'='image/jpeg','tmp_name'=>'D:\wamp\www\tmp','error'=>0,'size'=>2009347));其中,pic数组中的第一个单元name表示传递过来的文件的原名称,第二个单元type表示文件的MIME类型,第三个单元tmp_name表示把文件存储在临时目录里,第四个单元error表示该文件上传的错误代码,默认是0表示上传成功,第五个单元size表示上传文件的大小,单位为字节。error的错误代码有:0,表示文件上传成功,1,表示超过了文件大小php.ini中即系统设定的大小,2表示超过了文件大小MAX_FILE_SIZE选项指定的大小,3表示文件只有部分被上传,4表示文件没有被上传,5表示上传文件大小为0,6表示找不到临时目录,7表示写入失败。



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!