I
I
islam-4042021-09-21 23:38:59
PHP
islam-404, 2021-09-21 23:38:59

How to upload several files (photos) to the database at once through the site?

if (isset($_POST['upload'])) {
        var_dump(file_get_contents($_FILES['img_upload']['tmp_name']));
        if (!empty($_FILES['img_upload']['tmp_name'])) {
            $img = addslashes(file_get_contents($_FILES['img_upload']['tmp_name']));
            $connection1->query("INSERT INTO images (img) VALUES ('$img')");
        }
    }

this code only loads one at a time
<form action="index.php" method="post" enctype="multipart/form-data">
    <input type="file" name="img_upload" multiple="multiple">
    <input type="submit" name="upload" value="Загрузить">
    </form>


you can select more than one in the form, but only one is loaded (the last one selected)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
islam-404, 2021-09-22
@islam-404

name="img_upload[]"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question