1,105,406 Community Members

unable to retrieve multiple image from mysql

nawazsj
Newbie Poster
1 post since Jan 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 

please help me to display the multiple image from mysql

this id my file for uploading multiple image

$valid_formats = array("jpg", "jpeg", "png", "gif", "zip", "bmp", "pdf", "doc", "docx");
$max_file_size = 100000*100; //100 kb
$path = "uploads/"; // Upload directory
$count = 0;


        extract($_REQUEST);
    // Loop $_FILES to execute all files
    foreach ($_FILES['files']['name'] as $f => $name) {     
        if ($_FILES['files']['error'][$f] == 4) {
            continue; // Skip file if any error found
        }          
        if ($_FILES['files']['error'][$f] == 0) {              
            if ($_FILES['files']['size'][$f] > $max_file_size) {
                $message[] = "$name is too large!.";
                continue; // Skip large files
            }
            elseif( ! in_array(pathinfo($name, PATHINFO_EXTENSION), $valid_formats) ){
                $message[] = "$name is not a valid format";
                continue; // Skip invalid file formats
            }
            else{ // No error found! Move uploaded files 
                if(move_uploaded_file($_FILES["files"]["tmp_name"][$f], $path.$name)) {

                    $query1=mysqli_query($conn,"INSERT INTO `nation`.`photoup` (`id`, `photos`) VALUES (NULL, '$path.$name')");
                    //$sq=mysqli_query($conn,"update uploads set photo='$path.$name' where id='$count'");
                                //set photo='$path.$name' where id='$count'");
                  if($query1==true)
                {
                 echo "file uploaded";
                 }

                 echo $count;
                    $count++; // Number of successfully uploaded files
                }
            }
            /* $result=mysqli_query($conn,"select photos from photoup");
                 $row=mysqli_fetch_array($result);
                 echo "<img src='".$row['photos']."'height='200px' width='300px'>"; */

        }?>
        <body>
        <img src="getimage.php?id=<?php echo $id; ?>" width="175" height="200" />
        <body>
<?php        
    }
    ?>

`

this ist the file for retrieving image from mysql..but am unable display image in the browser


<?php
  include(confi.php);
 // $id = $_GET['id'];
  // do some validation here to ensure id is safe
  $sql = mysqli_query($conn,"select photos from photoup where id=13");
  $result = mysqli_query("$sql");
  $row = mysqli_fetch_assoc($result);

  header("Content-type: image/jpg");
   header("Content-type: image/jpeg");
    header("Content-type: image/png");

  echo $row['photos'];
?>

Heading Here

`

Member Avatar
pritaeas
mod_pritaeas
11,316 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
0
 

Looks like you upload the path into the table, so you should just output

echo "<img src=\"{$row['photos']}\"/>";
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article