Multi-File Upload Example _php Foundation
Last Update:2017-01-18
Source: Internet
Author: User
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" >
<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" >
<TD colspan= "2" height= "1" >
</td>
<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 "?>