上传网站的文件表单,似乎可以工作,但目录中没有文件



这是代码。。有什么想法吗?目录存在并且具有777权限。。。

<html>
<head>
 </head>
<body>
<div style="width:340px; border: 2px solid #fff;">
<br> <center>

<p>We only accept files with a .jpg, .gif or .jpeg extension</p>
<?php  
  //Define some variables  
      $dir = "http://www.mywebsite.com/media/uploads/"; //B?n nên thay ð?i ðý?ng d?n cho phù h?p  
    //Ki?u file, Gif, jpeg, zip ::b?n có th? s?a ð?i n?u thích  
      $types = array("image/gif","image/pjpeg","image/pjpg","application/x-zip-compressed");  
//Check to determine if the submit button has been pressed  
    if(isset($_POST['submit'])){  
//Shorten Variables  
     $tmp_name = $_FILES['upload']['tmp_name'];  
     $new_name = $_FILES['upload']['name'];  
//Check MIME Type  
    if (in_array($_FILES['upload']['type'], $types)){  
         //Move file from tmp dir to new location  
        move_uploaded_file($tmp_name,$dir . $new_name);  
        echo "<strong>{$_FILES['upload']['name']} was uploaded sucessfully, we will be touch!</strong>";                                          
    }else{  
    //Print Error Message  
     echo "<small>File <strong><em>{$_FILES['upload']['name']}</em></strong> was not uploaded</small><br />";  
    //Debug  
   $name =  $_FILES['upload']['name'];  
   $type =    $_FILES['upload']['type'];  
   $size =    $_FILES['upload']['size'];  
   $tmp =     $_FILES['upload']['name'];  
   echo "Name: $name<br/ >Type: $type<br />Size: $size<br />Tmp: $tmp";  
    }  
    }        
else{        
    echo '';  
}  
        ?>  
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">  


      <fieldset>  

          <div style="padding-left: 90px;"><input type="file" name="upload" />  </div>
</fieldset>
<br>  
<input type="submit" name="submit" value="Upload File" />  </center>
</form></div></body></html>

这是包含图像的文件夹的路径吗?如果脚本位于本地主机上,您需要更改路径,您说它有777权限,所以我猜您使用的是linux主机。

$dir = "http://www.mywebsite.com/media/uploads/";

猜测/media/位于您的根文件夹中,请尝试

$dir = "./media/uploads/";

相关内容

  • 没有找到相关文章

最新更新