《PHP应用:php 使用html5实现多文件上传实例》要点:
本文介绍了PHP应用:php 使用html5实现多文件上传实例,希望对您有用。如果有疑问,可以联系我们。
PHP编程首先向大家介绍一下html5中file的multiple属性
PHP编程定义和用法
PHP编程multiple 属性规定输入字段可选择多个值.如果使用该属性,则字段可接受多个值.
PHP编程实例:
PHP编程<form action="demo_form.asp" method="get"> Select images: <input type="file" name="img" multiple="multiple" /> <input type="submit" /></form>
PHP编程上面实例中的input file 可接受多个文件上传字段.
PHP编程了解了html5中file的multiple属性,下面我们开始讲解使用html5实现多文件上传.
PHP编程实例代码:
PHP编程html:
PHP编程<!DOCTYPE html><html><head><meta charset="UTF-8"></head><body><form action="my_parser.php" method="post" enctype="multipart/form-data"> <p><input name="upload[]" type="file" multiple="multiple" /></p> <input type="submit" value="Upload all files"></form></body></html>
PHP编程php代码:
PHP编程for($i=0; $i<count($_FILES['upload']['name']); $i++) { //Get the temp file path $tmpFilePath = $_FILES['upload']['tmp_name'][$i]; //Make sure we have a filepath if ($tmpFilePath != ""){ //Setup our new file path $newFilePath = "./uploadFiles/" . $_FILES['upload']['name'][$i]; //Upload the file into the temp dir if(move_uploaded_file($tmpFilePath, $newFilePath)) { //Handle other code here } }}
PHP编程感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
转载请注明本页网址:
/jiaocheng/2962.html
希望以上内容对你有所帮助!如果还有其他问题,请随时提问。 各类知识收集 拥有多年CMS企业建站经验,对 iCMS, LeCMS, ClassCMS, Fastadmin, PbootCMS, PHPCMS, 易优CMS, YzmCMS, 讯睿CMS, 极致CMS, Wordpress, HkCMS, YznCMS, WellCMS, ThinkCMF, 等各类cms的相互转化,程序开发,网站制作,bug修复,程序杀毒,插件定制都可以提供最佳解决方案。