diff options
| author | Gaspard Coulet <gaspard.coulet@mines-ales.org> | 2021-04-28 23:12:36 +0200 |
|---|---|---|
| committer | Gaspard Coulet <gaspard.coulet@mines-ales.org> | 2021-04-28 23:12:36 +0200 |
| commit | b4c345e6a5fa929ba20eac19183b9c777055f52d (patch) | |
| tree | 23a0232f2526c5ab7f53391609a8a0a5960865f0 /javascript_network/upload.php | |
Initial commit
Diffstat (limited to 'javascript_network/upload.php')
| -rw-r--r-- | javascript_network/upload.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/javascript_network/upload.php b/javascript_network/upload.php new file mode 100644 index 0000000..3ab6b22 --- /dev/null +++ b/javascript_network/upload.php @@ -0,0 +1,37 @@ +<?php +$target_dir = "uploads/"; +$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); +$uploadOk = 1; +$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); +if(isset($_POST["submit"])) { + $check = true; + if($check !== false) { + echo "Correct file - " . $check["mime"] . "."; + $uploadOk = 1; + } else { + echo "Incorrect file."; + $uploadOk = 0; + } +} + +if ($_FILES["fileToUpload"]["size"] > 500000) { + echo "Sorry, your file is too large."; + $uploadOk = 0; +} + +if($imageFileType != "nn" ) { + echo "Sorry, only .nn files are allowed."; + $uploadOk = 0; +} +if ($uploadOk == 0) { + echo "Sorry, your file was not uploaded."; +// if everything is ok, try to upload file +} else { + if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { + echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; + header("Refresh:0"); + } else { + echo "Sorry, there was an error uploading your file."; + } +} +?> |
