本文章利用了php多文件上传类来实现,多文件上传最主要就是关于file的属性必须以数组形式并且用foreach或for也读取来一个个用move_uploaded_file把文件上传到服务器这样就实现的多文件上传哦。
代码如下 |
复制代码 |
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.phprm.com/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=gb2312" /> <title>php多文件上传代码</title> </head> <body> <form method="post" enctype="multipart/form-data" action="server.php"> <input type="file" name="spec[]"> <input type="file" name="spec[]"> <!--<input type="file" name="spec"> <input type="file" name="manual">--> <input type="submit"> </form> </body> </html>
server.php <?php //upload array files include 'upload.class.php'; $u = new upload('../uploads/product/','spec','group'); print_r($u->getnewname()); echo $u->geterror(); /*********************** //upload single file $u = new upload('../www.phprm.com/product/','spec'); print_r($u->getnewname()); $u = new upload('../mb.phprm.com/product/','manual'); print_r($u->getnewname()); echo $u->geterror(); ************************/ ?> |
文章链接:http://www.phprm.com/develop/34240.html
随便收藏,请保留本文地址!