I'm trying to upload multiple images into my FTP server using PHP form.
I have folder to storage photos on server: (/domains/mydomain.com/public_html/static/img/storage/location
).
Current code doesn't want to upload images to my server for no reason. Where I made a mistake? Also I want to get url from this image as for example: https://example.com/static/img/storage/location/imagename.jpg
in $image_1
string.
HTML
<form method='POST' enctype='multipart/form-data'>
<input type='file' name='image[]' class='upload' accept='image/*' multiple/>
</form>
PHP
$image = $_POST['image'];
// uploading images to storage folder
$target = './static/img/storage/location/';
$count = 0;
foreach ($_FILES['image']['name'] as $filename) {
$tmp = $_FILES['image']['tmp_name'][$count];
$count = $count + 1;
$temp = $target.basename($filename);
move_uploaded_file($tmp, $temp);
$temp = '';
$tmp = '';
}
$image_0 = $_FILES['image']['name'][0];
$image_1 = $_FILES['image']['name'][1];
$image_2 = $_FILES['image']['name'][2];
$image_3 = $_FILES['image']['name'][3];
$image_4 = $_FILES['image']['name'][4];
$db->Query("INSERT INTO user_image (image_0, image_1, image_2, image_3, image_4) VALUES ('$image_0', '$image_1', '$image_2', '$image_3', '$image_4')");