1.$_FILES –超全局变量,HTTP 文件上传变量
通过 HTTP POST 方式上传到当前脚本的项目的数组,PHP 能够接受任何来自符合 RFC-1867 标准的浏览器上传的文件,
上传的过程中,文件存放在/tmp/phpXxXxx里,有的时候磁盘满了,/tmp/下放不了文件也会报错
2.RFC 1867标准
RFC 1867 – Form-based File Upload in HTML
<FORM ENCTYPE=”multipart/form-data” ACTION=”_URL_” METHOD=POST>
File to process: <INPUT NAME=”userfile1″ TYPE=”file”>
<INPUT TYPE=”submit” VALUE=”Send File”>
</FORM>
2.move_uploaded_file ( string $filename , string $destination )
将上传的文件移动到新位置,企邮默认从/tmp/phpxxxx到/mnt/entmail/webapp/uploads
3.上传多个文件
<input name=”userfile[]” type=”file” /><br />
<input name=”userfile[]” type=”file” /><br />
获取$_FILES[‘userfile’][‘tmp_name’][0],$_FILES[‘userfile’][‘tmp_name’][1]
5.对 PUT 方法的支持,使用标准的输入流,$putdata = fopen(“php://stdin”, “r”);
<?php /* PUT data comes in on the stdin stream */ $putdata = fopen("php://stdin", "r"); /* Open a file for writing */ $fp = fopen("myputfile.ext", "w"); /* Read the data 1 KB at a time and write to the file */ while ($data = fread($putdata, 1024)) fwrite($fp, $data); /* Close the streams */ fclose($fp); fclose($putdata); ?>
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/industrynews/12574.html