Jump to content

Klarez

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by Klarez

  1. Hi ,

    please i need help
    I created a php upload function to upload some photos to the database. Created a form
    <form action="upload.php" enctype="multipart/form-data" method="POST">
                <input class="pl-2 input" type="file" name="image" id="image"><br>
                <input class="send" type="submit" value="upload picture" name="upload">
        </form>
    and in another file called upload.php
    <?php
    if (isset($_POST['upload'])){
        $filename=$_FILES['image']['name'];
        $tempname=$_FILES['image']['tmp_name'];
        $filesize=$_FILES['image']['size'];
        $filetype=$_FILES['image']['type'];
        
            $folder="images/" . $filename;

        $conn=mysqli_connect("localhost","root","","mojeslike");
        mysqli_query($conn,"INSERT INTO photos(image) VALUES ('{$filename}')");
        if(move_uploaded_file($tempname,$folder)){
            echo "image uploaded successfully";
        }else{
            echo "failed to upload";
        }
    }
    ?>
     in a body tag
        <section class="container first">
    <h1>PICTURE GALLERY</h1>

        <article>
            <?php
                $rez=mysqli_query($conn,"SELECT * FROM photos");
                while($row=mysqli_fetch_array($rez)){
            ?>
                    <div class="photo">
                        <img src="<?php echo $row['image']; ?>" >
                        <div>
      
      <!-- Button to Open the Modal -->
      <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
        <h4>about picture</h4>
      </button>

      <!-- The Modal -->
      <div class="modal fade" id="myModal">
        <div class="modal-dialog modal-sm">
          <div class="modal-content">
          
            <!-- Modal Header -->
            <div class="modal-header">
              <h4 class="modal-title">Image details</h4>
              <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>
            
            <!-- Modal body -->
                
            <!-- Modal footer -->
            <div class="modal-footer">
              <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
            </div>
            
          </div>
        </div>
      </div>
    </div>
                    </div>
            <?php
    }
            ?>
        </article>
    <div class="clearfix"></div>
    </section>

    there is also a css file with styling, which is why this clearfix was included


    means, in one div tag I have an image and a bootstap modal. Another image is always displayed, and when I click on the button below the image, I would like them to show me data about the image. if I put echo $filesize and echo $filetype in the body of the modal, I get data about the last upload picture. I want to always have another data, each picture to display its own data, but I don't know that, so please help me with this problem. Thank you.

×
×
  • Create New...