Home >Backend Development >PHP Tutorial > 关于$_FILES的有关问题

关于$_FILES的有关问题

WBOY
WBOYOriginal
2016-06-13 12:47:081391browse

关于$_FILES的问题
在一台电脑上完全正常的代码,换电脑之后出问题了,可能是哪里的问题呢?求助各位大神
页面乱码,功能也不能用了

<br />
<html> <br />
<br />
<head> <br />
<br />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <br />
<br />
<title>文件上传</title><br />
<link rel="stylesheet" href="Images/CssAdmin.css"><br />
</head> <br />
<br />
<body> <br />
<br />
<form enctype="multipart/form-data" action=upfile.php?Result=<?php error_reporting(0); echo $_GET["Result"];?> method=post>  <br />
<br />
<input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <br />
<br />
<input name=upfile type=file class="button" size=40> <br />
<br />
<input type=submit class="button" value='上传文件'>  <br />
<br />
</form>  <br />
<br />
</body> <br />
<br />
</html><br />
<? <br />
<br />
function getname($exname){ <br />
<br />
   $dir = "uploadfile/"; <br />
<br />
   $i=1; <br />
<br />
   if(!is_dir($dir)){ <br />
<br />
      mkdir($dir,0777); <br />
<br />
   } <br />
<br />
<br />
   while(true){ <br />
<br />
     if(!is_file($dir.$i.".".$exname)){ <br />
<br />
        $name=$i.".".$exname; <br />
<br />
        break; <br />
<br />
      } <br />
<br />
     $i++; <br />
<br />
   } <br />
<br />
<br />
   return $dir.$name; <br />
<br />
} <br />
<br />
<br />
$exname=strtolower(substr($_FILES['upfile']['name'],(strrpos($_FILES['upfile']['name'],'.')+1))); <br />
<br />
$uploadfile = getname($exname);  <br />
<br />
<br />
if (move_uploaded_file($_FILES['upfile']['tmp_name'], $uploadfile)) { <br />
<br />
   echo "<font color=#ff0000>文件上传成功!</font>"; <br />
	echo "<input name='CopyPath' type='button' class='button' value='拷贝文件路径'  onclick=CopyPath('$uploadfile','".$_POST['Result']."')>";<br />
   echo "<br>下面是文件上传的一些信息: <br />
<br />
    <br>原文件名:".$_FILES['upfile']['name'] . <br />
<br />
    "<br>类型:" .$_FILES['upfile']['type'] . <br />
<br />
    "<br>临时文件名:".$_FILES['upfile']['tmp_name']. <br />
<br />
    "<br>文件大小:".$_FILES['upfile']['size']; <br />
}<br />
<br />
<br />
?><br />
<script language="JavaScript"> <br />
<!-- <br />
function CopyPath(FilePath,FileSize)<br />
{<br />
   // var str=location.toString()<br />
   // var Result=((((str.split('?'))[1]).split('='))[1]);<br />
	//window.opener.form1.FileSize.focus();								<br />
	window.opener.document.form1.<?php echo $_GET["Result"];?>.value=FilePath;<br />
    //if (Result == "FileUrl")<br />
//	{<br />
//	   window.opener.document.form1.FileSize.value=FileSize;<br />
//    }<br />
	window.opener=null;<br />
    window.close();<br />
}<br />
//--> <br />
</script> <br />
<br />

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn