summaryrefslogtreecommitdiff
path: root/javascript_network/upload.php
diff options
context:
space:
mode:
Diffstat (limited to 'javascript_network/upload.php')
-rw-r--r--javascript_network/upload.php37
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.";
+ }
+}
+?>