2 $target_dir = "esercizi/";
3 $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
5 $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
6 // Check if file already exists
7 if (file_exists($target_file)) {
8 echo "Sorry, file already exists.";
12 if ($_FILES["fileToUpload"]["size"] > 500000) {
13 echo "Sorry, your file is too large.";
16 // Check if $uploadOk is set to 0 by an error
18 echo "Sorry, your file was not uploaded.";
19 // if everything is ok, try to upload file
21 if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
22 echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
24 echo "Sorry, there was an error uploading your file.";
27 echo exec("php-cli main.php");
34 <form action="upload.php" method="post" enctype="multipart/form-data">
35 Select file to upload:
36 <input type="file" name="fileToUpload" id="fileToUpload">
37 <input type="submit" value="Upload" name="submit">