Displaying image uploaded in PHP

General Tech Bugs & Fixes 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I have uploaded the image and stored in the path Application/Photo but somehow I am unable to retrieve it.

php
$app = $_POST['app'];
$dbLink = mysqli_connect('localhost','root','','another');
$sql = "SELECT * FROM lama WHERE app = '$app'";
$sth = mysqli_query($dbLink,$sql);
while($row=mysqli_fetch_array($sth)) {?>
php echo $row['photoname']; ?>" height="250px" width="190px"/>
php
}
?>
//Below is the code I used to upload the image

$puploads_dir = 'Application/Photo';

$pname = $_FILES["photo"]["name"]; 
$tname=$_FILES["photo"]["tmp_name"];

$photoname = pathinfo($_FILES['photo']['name'], PATHINFO_FILENAME);
$extensionp = pathinfo($_FILES['photo']['name'], PATHINFO_EXTENSION);

 $incrementp = 0; 
 $pname = $photoname . '.' . $extensionp;
 while(is_file($puploads_dir.'/'.$pname)) {
 $incrementp++;
 $pname = $photoname . $incrementp . '.' . $extensionp;
 }
 move_uploaded_file($tname, $puploads_dir.'/'.$pname);
 $query = "
        INSERT INTO `lama` (
            `photoname` )
        VALUES (
         '{$pname}')";

I have also uploaded the code I used for uploading the image.

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.