I'm doing a react project and I just don't know if there is an error in the backend or frontent, so I tried the php file and I see that there is an error in it, so any advice please?
Checked php.ini and file_uploads=On
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$target_dir = '/var/www/html/server/uploaded/products_images/';
$target_file = $target_dir . basename($_FILES['files']['name']);
if (move_uploaded_file($_FILES['files']['tmp_name'], $target_file)) {
echo 'The file '. htmlspecialchars( basename( $_FILES['files']['name'])). ' has been uploaded.';
} else {
echo 'Sorry, there was an error uploading your file.';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form method='post' enctype='multipart/form-data' action='product_create_image_upload.php'>
<input type='file' multiple accept='image/*' name='files'>
<input type='submit' value='send'>
</form>
</body>
</html>