diff --git a/file.php b/file.php new file mode 100644 index 0000000..b33c398 --- /dev/null +++ b/file.php @@ -0,0 +1,39 @@ + diff --git a/index.php b/index.php new file mode 100644 index 0000000..c792d29 --- /dev/null +++ b/index.php @@ -0,0 +1,32 @@ + + + FileDrive + + + + + +
+
+ +
+ +
+
+
+ + diff --git a/list.php b/list.php new file mode 100644 index 0000000..9915161 --- /dev/null +++ b/list.php @@ -0,0 +1,26 @@ +" . "" . $title . "" . "" . $ext . "" . "" . $date . "" . "" . "View " . "" . ""; + } else { + return "" . "" . $title . "" . "" . $ext . "" . "" . $date . "" . "" . "Download " . "" . ""; + + } +} +$files = json_decode(file_get_contents("uploads/files.json")); +?> + + + + + + + title, $file->ext, $file->date, $file->download); + } + ?> + +
Title.Ext.Date.Links.
diff --git a/static/background.png b/static/background.png new file mode 100644 index 0000000..64d3e69 Binary files /dev/null and b/static/background.png differ diff --git a/static/upload.png b/static/upload.png new file mode 100644 index 0000000..2772771 Binary files /dev/null and b/static/upload.png differ diff --git a/static/upload2.png b/static/upload2.png new file mode 100644 index 0000000..6643fb8 Binary files /dev/null and b/static/upload2.png differ diff --git a/style.css b/style.css new file mode 100644 index 0000000..cea4d96 --- /dev/null +++ b/style.css @@ -0,0 +1,40 @@ +body{ + background:url("static/background.png"); +} + +#sidebar{ + background:#222; + padding:10px; +} +#submit{ + background:#333; + color:#eee; +} +#fileTitle{ + background:#333; + color:#eee; +} +#fileAttachmentLabel{ + height:200px; + padding-top:50px; + cursor:pointer; +} +#fileAttachment{ + width: 0.1px; + height: 0.1px; + opacity: 0; + overflow: hidden; + position: absolute; + z-index: -1; +} +#sort{ + border-top:1px solid #ddd; + border-bottom:1px solid #ddd; + padding:2px; + color:ddd; + text-align:center; +} +#list{ + height:100%; + overflow-y: scroll; +} diff --git a/upload.php b/upload.php new file mode 100644 index 0000000..ed41da1 --- /dev/null +++ b/upload.php @@ -0,0 +1,55 @@ + substr($title, 0, 50), + "ext" => $ext, + "date" => date("Y/m/d g:i:s"), + "download" => $path + ); + // write to files.json + $file_list = fopen("uploads/files.json", "c+"); + if(flock($file_list, LOCK_EX)){ + $db = json_decode(fread($file_list, filesize("uploads/files.json"))); + print_r($db); + array_unshift($db, $file); + ftruncate($file_list, 0); + rewind($file_list); + fwrite($file_list, json_encode($db)); + fflush($file_list); + flock($file_list, LOCK_UN); + } else { + echo "Couldn't get the lock. Please try your upload again."; + } + fclose(); +} +//upload file +if(fileValid($_FILES["fileAttachment"])){ + if(move_uploaded_file($_FILES["fileAttachment"]["tmp_name"], $path)){ + echo "File upload successful"; + indexFile($ext, $path); + } else{ + echo "Upload failed."; + } +} +?> diff --git a/uploads/files.json b/uploads/files.json new file mode 100644 index 0000000..6d547aa --- /dev/null +++ b/uploads/files.json @@ -0,0 +1 @@ +[{"title":"Picture of monkey using a phone.","ext":"png","date":"2020\/09\/09 2:14:23","download":"uploads\/src\/5f591b7f3eda0.png-download"},{"title":"Picture of me creating a PHP application.","ext":"jpg","date":"2020\/08\/09 12:09:33","download":"uploads\/src\/5f2f76fd99e5d.jpg-download"}] diff --git a/uploads/src/5f2f76fd99e5d.jpg-download b/uploads/src/5f2f76fd99e5d.jpg-download new file mode 100644 index 0000000..cc29d97 Binary files /dev/null and b/uploads/src/5f2f76fd99e5d.jpg-download differ diff --git a/uploads/src/5f591b7f3eda0.png-download b/uploads/src/5f591b7f3eda0.png-download new file mode 100644 index 0000000..72cd227 Binary files /dev/null and b/uploads/src/5f591b7f3eda0.png-download differ