0

This code does not print the temporary name of the uploaded image as well does not upload any picture in my Photo folder. but print image name. it work others computer correctly . where is the problem? please help me. i am using php Version 5.6.20

<!DOCTYPE html>
<html>
<head>
  <title>Image Upload</title>
</head>

<body>
<?php 

if ($_SERVER["REQUEST_METHOD"] == "POST") 
{

  $destination = "Photo/".$_FILES['image']['name'];
   $filename    = $_FILES['image']['tmp_name'];   
  echo $destination; 
  echo "<br/>";
  echo $filename;   
  echo "<br/>";

  if (file_exists($destination))

 echo "Sorry, file already exists.";

 else
    move_uploaded_file($filename, $destination);
  $name=$_FILES['image']['name'];
  $tmp_name=$_FILES['image']['tmp_name'];

  echo $tmp_name;
}


?>

<form method="POST" enctype="multipart/form-data">

<table>

<tr>
   <td>Choose Image</td>
   <td><input type="file" name="image"/> </td>
</tr> 

<tr>
   <td>Description:</td>
   <td><textarea name="Description" rows="4" cols="40"/></textarea></td>
</tr>

<tr> 
   <td></td>

    <td> <input type="submit" name="submit_image" value="Submit"></td>
</tr> 
</table>
</form>

</body>
</html>

4 Answers 4

2
<!DOCTYPE html>
<html>
<head>
  <title>Image Upload</title>
</head>

<body>
<?php 

if(isset($_POST['submit_image'])) 
{

  $destination = "Photo/".$_FILES['image']['name'];
   $filename    = $_FILES['image']['tmp_name'];   
  echo $destination; 
  echo "<br/>";
  echo $filename;   
  echo "<br/>";

  if (file_exists($destination))

 echo "Sorry, file already exists.";

 else
    move_uploaded_file($filename, $destination);
  $name=$_FILES['image']['name'];
  $tmp_name=$_FILES['image']['tmp_name'];

  echo $tmp_name;
}


?>

<form method="POST" enctype="multipart/form-data">

<table>

<tr>
   <td>Choose Image</td>
   <td><input type="file" name="image"/> </td>
</tr> 

<tr>
   <td>Description:</td>
   <td><textarea name="Description" rows="4" cols="40"/></textarea></td>
</tr>

<tr> 
   <td></td>

    <td> <input type="submit" name="submit_image" value="Submit"></td>
</tr> 
</table>
</form>

</body>
</html>

I tried this code it is working for me. please give read write permission of your photo folder I think it will work for you.

Sign up to request clarification or add additional context in comments.

4 Comments

what is the problem occur
in my code i print uploaded image name and temporary name of that image and upload that image in a folder name 'Photo'. but problem is it print only name of this image but not print temp_name and not upload any image in my photo folder
please give 777 permission on your photo folder
sorry, its not working. i told it work other computer but not work in my computer i don't know what is the problem. thank you for your answer and comment
1

your code is working fine , check with 'Photo/' folder permission and tmp folder path too. ex : D:\xampp\tmp\phpDCD9.tmp.

2 Comments

try to put error_reporting(0); inside the script and check , what type of the error is getting
after print error_reporting(0) it showing output 22527. i don't understant this
1

Your code is perfectly working on my machine. I think you might want to check the directory name Photo to which the uploaded files are been stored. check your destination folder name inn your coding and defined folder name where your project is present are same. Kindly post your error or warning message so that it is easy to help.

1 Comment

i think everything is ok. i told that it work other computer but not working my computer. shit
0

i think this part write properly like this it will solve

if (file_exists($destination)){
 echo "Sorry, file already exists.";
 }else{
    move_uploaded_file($filename, $destination);
  $name=$_FILES['image']['name'];
  $tmp_name=$_FILES['image']['tmp_name'];
  echo $tmp_name;
}

4 Comments

done but not working, i don't know why its not printing temp_name in my computer. but it works other computer
not working it dosent mean you give wrong review to my question like that nobody will answer
dear i am not give that wrong review. you are trying to solve my problem why i give your comment wrong review?
some one give negative rank to my comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.