NameSilo

Need help

SpaceshipSpaceship
Watch
Impact
0
In my code i try to display the image from database but empty image gets displayed.Please help me to make this code work.Thanks in advance 8^X


<?php $target_path = 'uploads/';

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
//echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
$con=mysql_connect("localhost","root","");
mysql_select_db("athenaadminlogin") or die("cannot connect");
$image1= $_FILES['uploadedfile']['name'];
//echo $image;
$query="insert into image values('$image1')";
$result=mysql_query($query) or die('Error1'.mysql_error());

$query="select * from image";
$result1=mysql_query($query) or die('Error'.mysql_error());

while($row = mysql_fetch_array($result1))
{
//echo $row['image'];
$s=$row['image'];

echo "<img src='".$target_path.$s."' />";

}
//echo'<img src="'uploads/.uploadedfile.'" />';
} else{
//echo "There was an error uploading the file, please try again!";
}
?>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains โ€” AI StorefrontUnstoppable Domains โ€” AI Storefront
There could be a lot going wrong. For one thing I think your path is incorrect. You haven't exactly given us any useful information....
 
0
•••
I think it is your echo of the <img> that is wrong. At this point, $target_path has been set to the full uploaded image path (path + uploaded filename), so you'll be echoing the filename twice (path + uploaded filename + filename). If you remove this line:

Code:
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

then I think it will work better.

If it is still not working, I suggest you use "View Source" in your web browser to look at the generated HTML code and see if that matches your expectation. Also check using FTP that images are being uploaded and put into the expected directory.
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy โ€” Live Options
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back