php多文件上传实例

html部分:

<form enctype="multipart/form-data" action="upload.php" method="POST">
  <input type="hidden" name="MAX_FILE_SIZE" value="30000">
  Send this file: <input name="userfile0" type="file"><br>
  Send this file: <input name="userfile1" type="file"><br>
  Send this file: <input name="userfile2" type="file"><br>
  Send this file: <input name="userfile3" type="file"><br>
  <input type="submit" value="Send File">
 </form>

upload.php

<? php
//  在 4.1.0 以前的 PHP 中,需要用 $HTTP_POST_FILES 代替 $_FILES。
// 在 4.0.3 以前的 PHP 中,需要用 copy() 和 is_uploaded_file() 来代替 move_uploaded_file()。


$uploaddir   =   ' upload/ ' ;
for ( $i = 0 ; $i < 4 ; $i ++ ){
    
$uploadfile   =   $uploaddir .   $_FILES [ ' userfile ' . $i ][ ' name ' ];
    
print   " <pre> " ;
    
if  ( move_uploaded_file ( $_FILES [ ' userfile ' . $i ][ ' tmp_name ' ] ,   $uploaddir   .   $_FILES [ ' userfile ' . $i ][ ' name ' ])) {
        
print   " File is valid, and was successfully uploaded.  Here's some more debugging info: " ;
        
print_r ( $_FILES );
    } 
else  {
        
print   " Possible file upload attack!  Here's some debugging info: " ;
        
print_r ( $_FILES );
    }
    
print   " </pre> " ;
}
?>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值