简体   繁体   中英

upload image file to server using php

I am trying to upload selected image file into my ftp server on 1and1. I am not able to upload the file.

I have created folder called "uploadimages".

I have created a html form which has the following:

<form action="add.php" method="POST" enctype="multipart/form-data">
  <div class="logo">
     <label for="logoname" class="styled">Upload Logo (jpg / png):</label>
     <div class="logofield">
     <input type="file" id="logo" name="logo" size="30"/>               
     </div>
 </div>
 <input type="submit" value="Upload"  name="submit" id="submit"/>
</form>

I have also create a php file which has the following:

 <?php

   $imagepic = $_FILES["logo"]["name"];
   echo $imagepic;
   $tempimgloc = $_FILES["logo"]["tmp_name"];
   echo $tempimgloc;
   $errorimg = $_FILES["logo"]["error"];
   echo $errorimg;

   if($errorimg > 0)
   {  
      echo "<strong> <font size='18'>There was a problem uploading your Logo. Please try again!</font></strong>";
  echo "<BR>";
   }
   else 
   {
      move_uploaded_file($tempimgloc, "uploadimages/".$imagepic);
   }
?>

ECHO printed results are:

1. Filename = testimage.png
2. Temp directory = /tmp/phpHvewUP
3. Error = 0 

But they are not getting uploaded..

Where could I go wrong here?

Let me know!

You need to give access to your folder. Try this, chmod 777 uploadimages .

chmod 777 uploadimages

WRITING PERMISSION was the issue. Thanks Shapeshifter!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM