zoukankan      html  css  js  c++  java
  • [PHP] 超全局变量$_FILES上传文件

    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);
    ?>
  • 相关阅读:
    Win7。56个进程让我头疼
    bzoj2843极地旅行社
    bzoj2751[HAOI2012]容易题(easy)
    bzoj3442学习小组
    bzoj4423[AMPPZ2013]Bytehattan
    bzoj4591[Shoi2015]超能粒子炮·改
    bzoj2299[HAOI2011]向量
    bzoj3223Tyvj 1729 文艺平衡树
    bzoj2563阿狸和桃子的游戏
    bzoj3673可持久化并查集 by zky&&bzoj3674可持久化并查集加强版
  • 原文地址:https://www.cnblogs.com/taoshihan/p/8377457.html
Copyright © 2011-2022 走看看