文件上载界面&lt

 代码如下

if(!$uploadaction):
?>

<html>
<head>
<title>文件上载分界面</title>
</head>
<body>

<table>
<tr align="center">
<td><form enctype="multipart/form-data" name="submitform" action="upload.php" method="post">
<input type="hidden" name="max_file_size" value="1000000"><input type="hidden" name="uploadaction" value="1">
</td></tr>
<tr align="center">
<td><input name="uploadfile" type="file" size="30"></td>
</tr>
<tr align="center">
<td><input name="submit" value="提交" type="submit"></td>
<td><input name="reset" value="重置" type="reset"></td>
</tr>
</form>
</table>
</center>
</body>
</html>

<?
else:
?>

<html>
<head>
<title>文件上载代码</title>
</head>
<body>

<?
$uploadaction=0;
echo "good!";
$timelimit=60; /*设置超时间限制制时间 缺省时间为30秒 设置为0时为不有效期 */
set_time_limit($timelimit);

if(($uploadfile !="none" ))
{  
    $uploadpath=addslashes(dirname($path_translated))."upload"; //上载文件贮存路线

    $filename=$uploadpath.$uploadfile_name; //上载文件名

    if($uploadfile_size < 1024) //上载文件大小
    {
  $filesize=(string)$uploadfile_size." 字节"; 
 }
     elseif ($uploadfile_size <(1024 * 1024))
     {
  $filesize=number_format((double)($uploadfile_size/1024), 1) . " kb";
     }
  else{
  $filesize=number_format((double)($uploadfile_size / (1024 * 1024)), 1) . " mb";
     }
   
    if(!file_exists($filename))
    {
         if(copy($uploadfile,$filename))
         {  echo "文件 $uploadfile_name ($filesize)上载成功!"; }
         else
         { echo "文件 $uploadfile_name上载战败!"; }

         unlink($uploadfile);
    }
    else
    { echo "文件 $uploadfile_name已经存在!"; }
}
else
{ echo "你未有选取别的文件上载!"; }

set_time_limit(30); //苏醒缺省超时设置

?>

<br><a href = "upload.php">返回</a>

</body>
</html>

<?
endif;
?>

方法二

<html>
<head>
<title>文件上传</title>
</head>
<body>
<table>
<form enctype="multipart/form-data" name=myform method="post">
<tr><td>文件上传</td><td><input name="myfile" type="file"></td></tr>
<tr><td colspan="2"><input name="submit" value="上传" type="submit">
</form>
<?php
if(isset($submit)){
 if($myfile != "none") {
  $upload_dir = "c:winnt emp";
  $up=copy($myfile,$upload_dir);
  if($up==1) {
   print("文件上传成功!");
  }
  else {
   print ("文件上传退步.");
  }
  unlink ($myfile);
 }
 else {
  print("你未曾上传任何公文");   
 }
}
?>
</td></tr>
</table>
</body>
</html>

本文由金沙澳门官网-www.js333com-金沙js333com发布于金沙澳门官网计算机,转载请注明出处:文件上载界面&lt

您可能还会对下面的文章感兴趣: