<form method="post" enctype="multipart/form-data"  name="form1">
  <table>
    <tr> 
      <td><input name="pic" type="file" size="30"></td>
          </tr>
          <tr> 
          <td> 
           <input name="Submit" type="submit" id="Submit" value="Send">
             &nbsp;&nbsp;&nbsp;&nbsp;
            <input type="reset" name="Submit2" value="Reset">
             </td>
          </tr>
        </table>
</form><?php
if($Submit){
echo '<pre>';
print_r($_FILES);
echo '</pre>';
}
?>

解决方案 »

  1.   

    PHP接收到上传文件后会在你设的PHP临时目录里产生一个临时文件,而非你以前的真正文件你要在上传的页面用javascript记下你以前的文件名。燃后上传后将其copy("PHP临时文件",“文见本身的名称”);
      

  2.   

    <?php     
    include ("../../lib/setting.php");PangRight($SAS_SESSION[userlogin][spwd]);   
    if (count($HTTP_POST_VARS)>0){
        
    if(!empty($mydocfile)){
    //echo "cp ".$attachfile." ".$mydocfile.$filename;
    copy($attachfile,$mydocfile.$filename);
    }
    if(!empty($gdocfile)){
    //echo "cp ".$attachfile." ".$gdocfile.$filename;
    copy($attachfile,$gdocfile.$filename);
    }
    if(!empty($jishufile)){
    //echo "cp ".$attachfile." ".$gdocfile.$filename;
    copy($attachfile,$jishufile.$filename);
    }
    }
    ?>
    <HTML>
    <HEAD>
    <TITLE> :::::: </TITLE>
    <meta http-equiv="Content-Type" content="text/html; charset=<?php echo ${CHARSET_.$SAS_SESSION[language]}; ?>">
    <?php echo ${css_.$SAS_SESSION[language]}; ?><script language="javascript">
    function sendform(){
    if(document.dataform.attachfile.value==''){
    alert("请添加上传文件!");
    document.dataform.attachfile.focus();
    return false;
    } var fname='';
    var str=document.dataform.attachfile.value;
    fname=str.split("\\");
    document.dataform.filename.value=fname[fname.length-1];
    document.dataform.submit();

    }
    </script>
    </HEAD><body  leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" ><center>
    <table width="95%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td class="Td8">
    <table width="0" border="0" cellspacing="0" cellpadding="0">
      <tr> 
    <td class="Td8" width="19">&nbsp;</td>
    <td class="Td8a"><b>文档管理--文件上传</b></td>
    <td class="Td8" width="48">&nbsp;</td>
    <td class="Td8">&nbsp;</td>
      </tr>
    </table>
    </td>
    <td width="10" class="Td8">&nbsp;</td>
    </tr>
    </table>
    </center><form name="dataform" enctype="multipart/form-data" action="<?php echo $PHP_SELF;?>" method="post">
    <input type="hidden" name="filename">
    <center>
    <table width="95%" border="0" cellpadding="0" cellspacing="1" class="Font12px">
    <tr align="center"><td>
    <input type="checkbox" class="ip2" name="mydocfile" value="<?php echo $path->userfiles."/user/".$SAS_SESSION[userlogin][uloginid]."/";?>"
     <?php if(!empty($mydocfile)||(empty($mydocfile)&&empty($gdocfile)))echo "checked";?>>
    上传到我的文件夹&nbsp;&nbsp;&nbsp;
    <input type="checkbox" class="ip2" name="gdocfile" value="<?php echo $path->userfiles."/group/".$SAS_SESSION[userlogin][ugroupid]."/";?>" 
    <?php if(!empty($gdocfile)) echo "checked";?>>
    上传到部门文件夹
    <input type="checkbox" class="ip2" name="jishufile" value="<?php echo $path->userfiles."/jishu/";?>" 
    <?php if(!empty($gdocfile)) echo "checked";?>>
    上传到技术文件夹
    </td></tr>
    <tr align="center"><td>
    <input type="file" name="attachfile" size=30>
    &nbsp;<input type="button" name="cmdUp" value="提 交" class="ipSub" onclick="javascript:sendform();">
    </td></tr></table>
    </center>
    </form></BODY>
    </HTML>
      

  3.   

    以下摘自PHP手册上传表单:
    <form enctype="multipart/form-data" action="_URL_" method="post">
    <input type="hidden" name="MAX_FILE_SIZE" value="1000">
    Send this file: <input name="userfile" type="file">
    <input type="submit" value="Send File">
    </form>我们推荐您使用 $_FILES。……以上范例中 $_FILES 数组的内容如下所示。我们假设文件上传字段的名称如上例所示,为 userfile。 $_FILES['userfile']['name']
    客户端机器文件的原名称。 $_FILES['userfile']['type']
    文件的 MIME 类型,需要浏览器提供该信息的支持,例如“image/gif”。 $_FILES['userfile']['size']
    已上传文件的大小,单位为字节。 $_FILES['userfile']['tmp_name']
    文件被上传后在服务端储存的临时文件名。 $_FILES['userfile']['error']
      

  4.   

    我用uploadfile_name\uploadfile_type等解决问题了,谢谢各位