File upload code
view plaincopy to clipboardprint?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Document Upload</title>
</head>
<body>
<script language="javascript"><!--
Dynamically add file selection controls-->
function AddRow()
{
var eNewRow = ();
for (var i=0;i<1;i++)
{
var eNewCell = ();
= "<tr><td><input type='file' name='filelist[]' size='50'/></td></tr>";
}
}
// --></script>
<form name="myform" method="post" action="" enctype="multipart/form-data" >
<table width="400" border="0">
<!-- The post method and enctype="multipart/form-data" -->
<!-- Pass the URL of this page to -->
<input name="postadd" type="hidden" value="<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER["PHP_SELF"]; ?>" />
<tr><td>File Upload List
<input type="button" name="addfile" onclick="AddRow()" value="Addlist" /></td></tr>
<!-- filelist[] must be an array -->
<tr><td><input type="file" name="filelist[]" size="50" /></td></tr>
</table>
<input type="submit" name="submitfile" value="submit file" />
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Document Upload</title>
</head>
<body>
<script language="javascript"><!--
Dynamically add file selection controls-->
function AddRow()
{
var eNewRow = ();
for (var i=0;i<1;i++)
{
var eNewCell = ();
= "<tr><td><input type='file' name='filelist[]' size='50'/></td></tr>";
}
}
// --></script>
<form name="myform" method="post" action="" enctype="multipart/form-data" >
<table width="400" border="0">
<!-- The post method and enctype="multipart/form-data" -->
<!-- Pass the URL of this page to -->
<input name="postadd" type="hidden" value="<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER["PHP_SELF"]; ?>" />
<tr><td>File Upload List
<input type="button" name="addfile" onclick="AddRow()" value="Addlist" /></td></tr>
<!-- filelist[] must be an array -->
<tr><td><input type="file" name="filelist[]" size="50" /></td></tr>
</table>
<input type="submit" name="submitfile" value="submit file" />
</form>
</body>
</html>
Submit file code
view plaincopy to clipboardprint?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>File upload results</title>
</head>
<body>
<?php
if ($_POST["submitfile"]!="")
{
$Path="./".date('Ym')."/";
if (!is_dir($Path))//Create a path
{ mkdir($Path); }
echo "<div>";
for ($i=0;$i<count($filelist);$i++)
{ //The arrangement order of $_FILES["filelist"]["size"][$i] cannot be changed, because fileist is a two-dimensional array
if ($_FILES["filelist"]["size"][$i]!=0)
{
$File=$('Ymdhm')."_".$_FILES["filelist"]["name"][$i];
if (move_uploaded_file($_FILES["filelist"]["tmp_name"][$i],$File))
{ echo "File upload successfully File type:".$_FILES["filelist"]["type"][$i]." "."File name:"
.$_FILES["filelist"]["name"][$i]."<br>"; }
else
{ echo "Filename:".$_FILES["filelist"]["name"][$i]."Upload failed</br>"; }
}
}
echo "</div><br><a href="$postadd" href="$postadd">Return</a></div>";
}
?>
</body>
</html>
view plaincopy to clipboardprint?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Document Upload</title>
</head>
<body>
<script language="javascript"><!--
Dynamically add file selection controls-->
function AddRow()
{
var eNewRow = ();
for (var i=0;i<1;i++)
{
var eNewCell = ();
= "<tr><td><input type='file' name='filelist[]' size='50'/></td></tr>";
}
}
// --></script>
<form name="myform" method="post" action="" enctype="multipart/form-data" >
<table width="400" border="0">
<!-- The post method and enctype="multipart/form-data" -->
<!-- Pass the URL of this page to -->
<input name="postadd" type="hidden" value="<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER["PHP_SELF"]; ?>" />
<tr><td>File Upload List
<input type="button" name="addfile" onclick="AddRow()" value="Addlist" /></td></tr>
<!-- filelist[] must be an array -->
<tr><td><input type="file" name="filelist[]" size="50" /></td></tr>
</table>
<input type="submit" name="submitfile" value="submit file" />
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Document Upload</title>
</head>
<body>
<script language="javascript"><!--
Dynamically add file selection controls-->
function AddRow()
{
var eNewRow = ();
for (var i=0;i<1;i++)
{
var eNewCell = ();
= "<tr><td><input type='file' name='filelist[]' size='50'/></td></tr>";
}
}
// --></script>
<form name="myform" method="post" action="" enctype="multipart/form-data" >
<table width="400" border="0">
<!-- The post method and enctype="multipart/form-data" -->
<!-- Pass the URL of this page to -->
<input name="postadd" type="hidden" value="<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER["PHP_SELF"]; ?>" />
<tr><td>File Upload List
<input type="button" name="addfile" onclick="AddRow()" value="Addlist" /></td></tr>
<!-- filelist[] must be an array -->
<tr><td><input type="file" name="filelist[]" size="50" /></td></tr>
</table>
<input type="submit" name="submitfile" value="submit file" />
</form>
</body>
</html>
Submit file code
view plaincopy to clipboardprint?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>File upload results</title>
</head>
<body>
<?php
if ($_POST["submitfile"]!="")
{
$Path="./".date('Ym')."/";
if (!is_dir($Path))//Create a path
{ mkdir($Path); }
echo "<div>";
for ($i=0;$i<count($filelist);$i++)
{ //The arrangement order of $_FILES["filelist"]["size"][$i] cannot be changed, because fileist is a two-dimensional array
if ($_FILES["filelist"]["size"][$i]!=0)
{
$File=$('Ymdhm')."_".$_FILES["filelist"]["name"][$i];
if (move_uploaded_file($_FILES["filelist"]["tmp_name"][$i],$File))
{ echo "File upload successfully File type:".$_FILES["filelist"]["type"][$i]." "."File name:"
.$_FILES["filelist"]["name"][$i]."<br>"; }
else
{ echo "Filename:".$_FILES["filelist"]["name"][$i]."Upload failed</br>"; }
}
}
echo "</div><br><a href="$postadd" href="$postadd">Return</a></div>";
}
?>
</body>
</html>