0

how to upload multiple images with php and store the names in MySQL?

Marc Delisle
  • 8,879
  • 3
  • 29
  • 29
Logan 96
  • 91
  • 8
  • 1
    Possible duplicate of [Full Secure Image Upload Script](https://stackoverflow.com/questions/38509334/full-secure-image-upload-script) – icecub Aug 13 '17 at 07:33
  • Check the link in the comment above and then research using the PDO class to insert the names of the images. This is a simple google search for BOTH, we don't make the code for you. – MinistryOfChaps Aug 13 '17 at 07:56

1 Answers1

1

HTML Form:

<form name="upload" action="upload.php" method="POST" enctype="multipart/form-data">
    Select image to upload: <input type="file" name="image">
    <input type="submit" name="upload" value="upload">
</form>

Php File Code

<?php
$uploaddir = 'uploads/';

$uploadfile = $uploaddir . basename($_FILES['image']['name']);
$filename = $_FILES['image']['name'];
if (move_uploaded_file($_FILES['image']['tmp_name'], $uploadfile)) {
    echo "Image succesfully uploaded.";
print_r($filename);
//Store File Name $filename in DB;
    } else {
        echo "Image uploading failed.";
    }
?> 
jvk
  • 2,133
  • 3
  • 19
  • 28