I'm new in this forum so I'll hope to don't write wrong.
In these days I'm trying to create a professional website ad the person I'm doing this for asked me to make a dynamic gallery so he can upload images easily. This code in local works so well but when i put it into the real website it doesn't work.
<form action="admin.php" method="post" class="admin_form" enctype="multipart/form-data">
<p>Seleziona l'immagine che vuoi aggiungere alla galleria: </p><br>
<input type="file" name="file"><br><br>
<button class="home hover" type="submit" name="img">Aggiungi Foto</button><br>
</form>
<?php
if (isset($_POST['img'])){
$file = $_FILES['file'];
$fileName = $file['name'];
$fileType = $file['type'];
$fileTmpName = $file['tmp_name'];
$fileError = $file['error'];
$fileSize = $file['size'];
$fileExt = explode('.', $fileName);
$fileActualExt = strtolower(end($fileExt));
$allowed = array('jpg', 'jpeg', 'png');
if (in_array($fileActualExt, $allowed)){
if($fileError === 0){
if($fileSize < 1000000){
$fileNameNew = uniqid('', true);
$fileNameFull = $fileNameNew.".".$fileActualExt;
$fileDestination = '/home/cupidoeventi/img/galleria/';
move_uploaded_file($fileTmpName, $fileDestination);
header("Posizione: admin.php?uploadsucces");
$query = "INSERT INTO `galleria`(`nomeimmagine`) VALUES ('$fileNameFull')";
$inserisciDati = mysqli_query($connessione,$query);
if(!$inserisciDati){
die('Query fallita' . mysqli_error($connessione));
}
}else{
echo "<p>Il file è troppo pesante!</p>";
}
}else{
echo "<p>C'è stato un errore nel caricamento del file!</p>";
}
}else{
echo "<p>Non puoi caricare questo tipo di file!</p>";
}
}
?>
And the error that id gives to me is:
Warning: move_uploaded_file(/home/cupidoeventi/img/galleria/): failed to open stream: No such file or directory in /web/htdocs/www.onetvemilia.it/home/cupidoeventi/admin/admin.php on line 127 (I'm sure that this directory exist)
Warning: move_uploaded_file(): Unable to move '/tmp/phpSzEYpd' to '/home/cupidoeventi/img/galleria/' in /web/htdocs/www.onetvemilia.it/home/cupidoeventi/admin/admin.php on line 127