U
U
user12132018-03-24 11:00:15
PHP
user1213, 2018-03-24 11:00:15

Why are the pictures not showing up in the folder?

Pictures are stored in the upload folder. If I display the names of the pictures, then everything works; if I try to display the images, it displays a square of white lines on a
black screen. Pictures in jpeg format database.

<?php
Header('Content-Type: image/jpg'); 
$category=$_GET[category];
$host = 'localhost'; // адрес сервера 
$database = 'imagess'; // имя базы данных
$user = 'admin'; // имя пользователя
$password = '12345'; // пароль
$link = mysqli_connect($host, $user, $password, $database) 
    or die("Ошибка " . mysqli_error($link));


$res = mysqli_query($link,"SELECT name FROM imagess WHERE category='".$category."'");

  
  
    
 	
 	
 while($row = mysqli_fetch_array($res)) {
$src='upload/'.$row['name'];
?>
 <img src="<?php echo $src; ?>"/>

<?php		
}

mysql_close($conn);
?>

I think that the matter is in the line, I tried it in different ways, but it does not work to display the images.
$src='upload/'.$res['name'];

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Cyril, 2018-03-24
@stk

1. Have you checked the folder permissions?
2. The URL you get is "upload/...", that is, relative to the current URL of the page with pictures.
That is, if this page is "www.example.com/gallery", then the pictures will be "www.example.com/gallery/upload/...".
Add a slash $src = "/upload/...". Then the image source will be "www.example.com/upload/...".

D
Dmitry, 2018-03-24
@slo_nik

Good morning.
<img src="<? echo $src; ?>">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question