2 include './dbData.php';
3 $target_dir = "esercizi/";
4 $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
6 $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
7 // Check if image file is a actual image or fake image
8 /*if(isset($_POST["submit"])) {
9 $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
10 if($check !== false) {
11 echo "File is an image - " . $check["mime"] . ".";
14 echo "File is not an image.";
18 // Check if file already exists
19 if (file_exists($target_file)) {
20 echo "Sorry, file already exists.";
24 if ($_FILES["fileToUpload"]["size"] > 500000) {
25 echo "Sorry, your file is too large.";
28 // Allow certain file formats
29 /*if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
30 && $imageFileType != "gif" ) {
31 echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
34 // Check if $uploadOk is set to 0 by an error
36 echo "Sorry, your file was not uploaded.";
37 // if everything is ok, try to upload file
39 if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
41 $xml = simplexml_load_file($DATA['listaEsercizi']);
42 foreach($xml->esercizio as $esercizio)
44 if($esercizio==basename( $_FILES["fileToUpload"]["name"]))
46 echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
51 echo "Sorry, there was an error uploading your file.";
59 <form action="main.php">
60 <input type="submit" value="indietro" name="submit">