Multi-File Upload Example _php Foundation

Source: Internet
Author: User
Tags chop file upload

Multi-File Upload example//upload_ html.php---------------------------------------------------------------------------------------------
<HTML>
<HEAD>
<TITLE> Upload file </TITLE>
</HEAD>
<script>
function Beforesubmit (forma)
{
var Indexnamea=forma.indexname.value;
var Upfilea=forma.upfile.value;
var k=//g;
var indexnamea=indexnamea.replace (k, "");
var upfilea=upfilea.replace (k, "");
if (indexnamea== ""
upfilea== "")
{
Alert ("Directory name or uploaded directory cannot be empty!");
return false;
}
return true;
}
</script>
<body bgcolor=white>
<BR>
<form name=form1 action= "upload.php" Method=post enctype=\ "multipart/form-data\";
<table cellspacing= "1" cellpadding= "5" border= "0" width= "580" bgcolor= "#C2E2F5" >
<tr bgcolor= "#E3F2FB" align= "Center" >
&LT;TD width= "280" align= "center" height= "all" > uploaded files </td>
</tr>
?
For ($i =1 $i <8; $i + +)
{
$upfile = "Upfile". Strval ($i);
echo "<tr>\n";
echo "<td bgcolor= #F5FBFE width=264><input type=file name= $upfile lengh=25></td>\n";
echo "</tr>\n";
}
?>
<tr bgcolor= "#E3F2FB" >
&LT;TD colspan= "2" height= "1" >
</td>
&LT;TD colspan= "2" height= "1" >
<div align= "center" >
<input type=submit name= "submit" value= upload >
</div>
</td>
</table>
</form>
</body>//------------------------------------------------------------------------------------------------------------- ----------

upload.php-------------------------------------------------------------------------------------------------------------
Upload_path: directory path on which the file will be uploaded
<?php
For ($i =1 $i <8; $i + +)
{
$upfile = "Upfile". Strval ($i);
if (Chop ($ $indexname)!= "" and Chop ($ $upfile)!= "")
{
$upfilename = ($upfile. " _name ");
$filename =upload_path.$ $upfilename;
$copyfile = Copy ($ $upfile, $filename);
if (! $copyfile)
Die ("File upload failed!");
$ls _file.=$ $upfilename. " \ n ";
$flag = 1;
}
}
if ($flag) {
$ls _msg= "file \ n". $ls _file. " Upload success! ";
}
else{
$ls _msg= "No file upload, please choose again!";
}
echo "echo "echo "echo "<body >\n";
echo $ls _msg. " \ n ";
echo "</body>\n";
echo "?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.