I have a php form that should theoretically upload image files to a specific directory, but it does not do that. This is the HTML:
<!DOCTYPE html>
<html>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>
</body>
</html>
And this is the php:
<?php
$cartella_caricamento = "pagamenti/";
$file_caricato = $cartella_caricamento.basename($_FILES["fileToUpload"]
["name"]);
$uploadOk=1;
$imageFileType=pathinfo($file_caricato,PATHINFO_EXTENSION);
if(isset($_POST["submit"]))
{
$check = getimagesize($_FILES["fileToUpload"]["nome_upd"]);
if($check !== false) //Check if the file is an image
{
echo "Il file è un immagine, OK".$check["mime"].".";
$uploadOk=1;
} else {
echo "Il file non è un immagine.";
$uploadOk=0;
}
if ($_FILES["fileToUpload"]["size"] > 2000000) { //check the image size, if it is >2MB it refuses it
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
if ($uploadOk==0) {
echo "Il file non è stato caricato a causa di un errore";
} else {
if(move_uploaded_file($_FILES["file_caricato"]["nome_upd"], $file_caricato))
{
echo "Il file".basename($_FILES["fileToUpload"]["name"])."è stato caricato";
}else {
echo "C'è stato un errore nel caricamento del file.";
}
}
}
The problem is that when I run the page using XAMPP it says that in line 21
$check = getimagesize($_FILES["fileToUpload"]["nome_upd"]);
there is an undefined index (nome_tmp) and I don't know why And the image that I chose in the explorer window is not being uploaded to the directory "pagamenti/"