0

我在基于窗口的服务器上上传图像时出错,它在 localhost 和 linux 服务器上运行良好。首先,我在根目录中手动创建一个名为photos的文件夹和两个名为 imageupload.phpindex.php的文件

where code is

索引.php

     <html>        
      <body>
      <form enctype="multipart/form-data"  action="imageupload.php" method="post"> 
Choose Picture:<input type="file" name="photo"/>
       <input name="submit" type="submit" value="save"/>
        </form>
        </body>
      </html>    

图像上传.php

 <?php
  if(isset($_REQUEST['submit'])){
      $target = "photos/"; 
  $finallink = $target.basename($_FILES['photo']['name']);

     if(move_uploaded_file($_FILES['photo']['tmp_name'], $finallink)) 
   { 
 echo "The file ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory"; 
        } 
      else { 

 echo "Sorry, there was a problem uploading your file."; 
         } 
     }
    ?>

这段代码在 localhost 和 linux 服务器上运行良好,但我购买了一个基于窗口的主机,因为在基于窗口的 web 服务器上运行这段代码时出现错误

抱歉,上传您的文件时出现问题。

如何解决?这个问题是在基于窗口的服务器上运行的 php 代码还是其他任何东西?提前感谢您的帮助。

4

2 回答 2

0

试试这个代码希望它会帮助你

     if(isset($_REQUEST['submit'])){ move_uploaded_file($_FILES["photo"]["tmp_name"],
  "upload/" . $_FILES["photo"]["name"]);
  echo "Stored in: " . "upload/" . $_FILES["photo"]["name"]; }
于 2013-03-16T09:43:01.200 回答
0
move_uploaded_file($_FILES["companylogo"]["tmp_name"],"companylogo/" . $_FILES["companylogo"]["name"]);
      echo "Stored in: " . "companylogo/".$_FILES["companylogo"]["name"];
于 2013-05-28T11:21:23.460 回答