copy($thefile,$aNewName);
改成
copy($_FILES['thefile']['tmp_name'],$aNewName);
或者
move_uploaded_file($_FILES['thefile']['tmp_name'],$aNewName);

解决方案 »

  1.   

    PHP上传文件简单的啊,就是一个复制,因为PHP已经自动将文件存放到临时目录了
      

  2.   

    $_FILES['thefile']['tmp_name'],
    无内容是什么原因呢??
      

  3.   

    有几个地方需要注意:
    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>