]> matita.cs.unibo.it Git - logicplayer.git/blob - public_html/upload.php
server/log ignored
[logicplayer.git] / public_html / upload.php
1 <?php
2         include './dbData.php';
3         $target_dir = "esercizi/";
4         $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
5         $uploadOk = 1;
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"] . ".";
12                         $uploadOk = 1;
13                 } else {
14                         echo "File is not an image.";
15                         $uploadOk = 0;
16                 }
17         }*/
18         // Check if file already exists
19         if (file_exists($target_file)) {
20                 echo "Sorry, file already exists.";
21                 $uploadOk = 0;
22         }
23         // Check file size
24         if ($_FILES["fileToUpload"]["size"] > 500000) {
25                 echo "Sorry, your file is too large.";
26                 $uploadOk = 0;
27         }
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.";
32                 $uploadOk = 0;
33         }*/
34         // Check if $uploadOk is set to 0 by an error
35         if ($uploadOk == 0) {
36                 echo "Sorry, your file was not uploaded.";
37         // if everything is ok, try to upload file
38         } else {
39                 if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
40                         sleep(1);
41                         $xml = simplexml_load_file($DATA['listaEsercizi']);
42                         foreach($xml->esercizio as $esercizio)
43                         {
44                                 if($esercizio==basename( $_FILES["fileToUpload"]["name"]))
45                                 {
46                                         echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; 
47                                         die;
48                                 }
49                         }
50                 }
51                 echo "Sorry, there was an error uploading your file.";
52         }
53 ?>
54 <!DOCTYPE html>
55 <html>
56 <head>
57 </head>
58 <body>
59         <form action="main.php">
60                 <input type="submit" value="indietro" name="submit">
61         </form>
62 </body>