<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>上传文件</title> <style type="text/css"> <!-- .STYLE1 { font-size: 36px; color: #990000; font-weight: bold; } body,td,th { font-size: 12px; } --> </style> </head> <body> <div align="center"> <form action="uploading_ok.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> <table id="__01" width="800" height="600" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="523" height="251" align="center" valign="top"><table width="460" height="232" border="1" align="center"> <tr> <td width="150" height="30">文件名称:</td> <td width="310" align="left"><input name="fileName" type="text" size="40" /></td> </tr> <tr> <td width="150" height="30">文件上传:(<font color="#FF0000">.xls文件</font>)</td> <td align="left"><input name="files" type="file" size="31" /></td> </tr> <tr> <td height="30" colspan="2"><div align="center"> <input type="submit" name="Submit" value="上传" /> <input type="reset" name="Reset" value="取消" /> </div></td> </tr> </table></td> </tr> </table> </form> </div> </body> </html><pre name="code" class="php"><?php header("content-type:text/html;charset=utf-8"); if(isset($_POST['fileName']) and $_POST['Submit']=="上传") { if(isset($_FILES['files']['name'])) //判断文件是否存在 { $fileName = 'dir\\' . 'myfile'. ".xls"; //文件的存储路径和名称 $fileName = iconv("utf-8","gb2312//IGNORE",$fileName); if(move_uploaded_file($_FILES['files']['tmp_name'], $fileName)) { //执行上传 echo "<script>alert('上传成功!');</script>"; include("buildFile.php"); } else { echo "<script>alert('复制文件失败!');</script>"; } } else { echo "<script>alert('文件不存在!');</script>"; } } else { echo "<script>alert('请选择上传文件!');</script>"; } echo "<script>window.location.href='display_updata.php';</script>"; ?>
时间: 2024-10-09 07:47:34