<form method="post" action="" enctype="multipart/form-data">
<p>Scegli immagine da caricare: </p><input type="file" name="file"><br>
<p>Crea una cartella in cui salvare il file</p><input type="text" name="cartella"><br>
<input type="submit" value="Inserisci file" name="upload">
</form>
<?php
if($_SERVER["REQUEST_METHOD"]== "POST"){
class Upload{
public $cartella;
public $file;
public function Upload($c,$f){
$this->cartella = $c;
$this->file = $f;
}
public function caricamento(){
if(file_exists("$this->cartella/".$this->file)){
echo "immagine gia presente";
}
else{
move_uploaded_file($_FILES["file"]["tmp_name"], "$this->cartella/".$this->file);
echo "immagine caricata";
}
}
}
$obj = new Upload($_POST["cartella"],$_FILES["file"]["name"]);
$obj->caricamento();
}
?>