1

I am having problem with file uploading on my website as i am new to php.Please help me regarding this.Here is my code: and when i try to run to run this code it gives me error move_uploaded_file(/www.g-dms.com/livelink/livelink.exe?func=ll&objId=59413694&objAction=browse&viewType=1/Lighthouse.jpg) [function.move-uploaded-file]: failed to open stream: No error in C:\xampp\phpMyAdmin\filefile.php on line 30

<?php         
      $dir = "/www.g-dms.com/livelink/livelink.exe?func=ll&objId=59413694&objAction=browse&viewType=1/";
      $types = array("image/gif","image/jpeg","image/jpg","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>
  • 4
    You seriously have a directory called `livelink.exe?func=ll&objId=59413694&objAction=browse&viewType=1`? – Waleed Khan Feb 21 '13 at 12:51
  • Possible duplicate: [move_uploaded_file() failed to open stream](http://stackoverflow.com/questions/14596832/move-uploaded-file-failed-to-open-stream) – Boaz Feb 21 '13 at 12:52

2 Answers2

0

That is the weirdest Directory name I have ever seen. move_uploaded_file() takes two parameters. The first being the $_FILES['upload']['tmp_name'] which you appear to have grasped, the second is the destination.

juco
  • 6,331
  • 3
  • 25
  • 42
0

the dir name is not correct. moreover you need to make sure the dir has write permission use chmod 755 dirname to grant it the required permissions.

whizzzkid
  • 1,174
  • 12
  • 30