Jump to content

Recommended Posts

I have a small database and was wondering how i add images from a server (my hdd)

I have field the database with the following fields
.id
.song name
.artist
.track 1
.track 2
.track 3
.image

i have entered in about 10 entries in the database

but do not know how to upload images to image field

How can i do this (all the webpages that i have searched show how to add images but not in the order i would like)

i have no code yet

Thank you for your reply.

I have tried this but cannot get it add the filename to the database.

here is the code

<html>
    <body>
        <form method="POST" action="upload.php" enctype="multipart/form-data">
            <input type="file" name="image">
            <input type="submit" name="submit_image" value="Upload">
        </form>
        <?php
        $conn = mysqli_connect("localhost","root","","gameslibrary");

        if(isset($_POST['image'])) {
            $Get_image_name = $_FILES['image']['name'];
            $image_path = "upload/".basename($Get_image_name);

            $sql = "INSERT INTO test (image, contact) VALUES ('$Get_image_name' 'USA')";

            mysqli_query($conn, $sql);

            if(move_uploaded_file($_FILES['image']['tmp_name'], $image_path)) {
                echo "Your Image uploaded successfully";
            }else {
                echo "Not Insert Image";
            }
        }
        ?>
    </body>
</html>   

 

Thank you for your replay,

 

I have found a way to add the images to my database.

 

could anybody tell me how to show the image on my page

<?php foreach($games as $game): ?>
            
                        <!-- this is where the screenshot will go -->
                        <!-- <img src="images/2.png"> -->
                        <img src=<?php echo $game['id']?><?php echo <img src="uploads/ . $game['image']> ?>
                        <a href="details.php?id=<?php echo $game['id']?>"><?php echo $game['game']?></a>

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.