copy($thefile,$aNewName);
改成
copy($_FILES['thefile']['tmp_name'],$aNewName);
或者
move_uploaded_file($_FILES['thefile']['tmp_name'],$aNewName);
改成
copy($_FILES['thefile']['tmp_name'],$aNewName);
或者
move_uploaded_file($_FILES['thefile']['tmp_name'],$aNewName);
无内容是什么原因呢??
1. $aNewName=$aCurBasePath."uppics".$_FILES["thefile"]["name"];
修改为$aNewName=$aCurBasePath."/uppics/".$_FILES["thefile"]["name"];
2.需要提前创建好uppics这个目录
3.html代码,print("<img scr=\"$addr \" border=\"0\">");
修改为:print("<img src=\"$addr \" border=\"0\">");
在linux下测试如下代码成功:
<?php
$aErrors=""; if(!empty($_FILES["thefile"]["name"]))
{
if(($_FILES["thefile"]["type"]="image/gif")||($_FILES["thefile"]["type"]="image/pjpeg")||($_FILES["thefile"]["type"]="image/jpeg"))
{
if($_FILES["thefile"]["size"]<(1024*1000))
{
$aCurBasePath=dirname($PATH_TRANSLATED); $aNewName=$aCurBasePath."/uppics/".$_FILES["thefile"]["name"]; if(!is_dir($aCurBasePath."/uppics/"))
{
mkdir($aCurBasePath."/uppics/");
}
copy($_FILES["thefile"]["tmp_name"],$aNewName);
}
else {
$aErrors.="The file was too big";
}
}
else {
$aErrors.="No file was selected";
}
}
?>
<html>
<head>
<title>Display an Uploaded Image</title>
</head>
<body>
<?php
if($aErrors!="")
{
print ("<b>There were errors</b>:$aErrors<br/>");
}
else {
print("The picture you uploaded:<br/><br/>");
$addr="uppics/".$_FILES["thefile"]["name"];
print("<img src=\"$addr\" border=\"0\">");
}
?>
</body>
</html>