mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
usb_lib/files/upload2usb/*: renaming app to Upload To USB instead of HW Submission, other minor cleanup/styling
This commit is contained in:
parent
2706381a38
commit
99ff433a90
3 changed files with 18 additions and 28 deletions
|
@ -16,7 +16,7 @@ $file_count = getFileCount(getTargetFolderPath(0));
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<title>IIAB Homework Submission App</title>
|
||||
<title>IIAB Upload to USB App</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
|
@ -31,16 +31,16 @@ $file_count = getFileCount(getTargetFolderPath(0));
|
|||
<div class="row">
|
||||
<div class="col-sm-6 offset-sm-3 text-center" style="padding:15px;">
|
||||
|
||||
<form action="submit-hw.php" id="hw_submission_form" method="post" enctype="multipart/form-data">
|
||||
<img class="mb-4" src="unleash-kids-swing.png" alt="" width="75">
|
||||
<h1 class="h3 mb-3 font-weight-normal">Internet in a Box Homework Submission</h1>
|
||||
<form action="upload-file.php" id="upload2usb_form" method="post" enctype="multipart/form-data">
|
||||
<img class="mb-4" src="uk-swing.png" alt="" width="75">
|
||||
<h1 class="h3 mb-3 font-weight-normal">Internet in a Box Upload to USB</h1>
|
||||
|
||||
<label for="submit_hw" style="font-weight:bold;padding-bottom:10px;">Submit your homework here!</label>
|
||||
<input type="file" name="hw_submission" id="hw_submission"><br/><br/>
|
||||
<label for="upload2usb" style="font-weight:bold;padding-bottom:10px;">Upload your file here!</label>
|
||||
<input type="file" name="uploaded_file" id="uploaded_file"><br/><br/>
|
||||
<button class="btn btn-dark" name="submit" type="submit" style="width:150px;">Submit</button>
|
||||
</form>
|
||||
<br/>
|
||||
<?php echo $file_count ?> homework files have been submitted today!
|
||||
<?php echo $file_count ?> files have been uploaded today!
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
|
||||
include("upload2usb.php");
|
||||
|
||||
//get folder path where homework will be stored
|
||||
//get folder path where file will be stored
|
||||
$target_folder_path = getTargetFolderPath(1);
|
||||
$target_file = $target_folder_path . "/" . basename($_FILES["hw_submission"]["name"]);
|
||||
$target_file = $target_folder_path . "/" . basename($_FILES["uploaded_file"]["name"]);
|
||||
$upload_ok = 1;
|
||||
$upload_msg = "";
|
||||
|
||||
if(!isset($_POST["submit"]) || empty(basename($_FILES["hw_submission"]["name"]))) {
|
||||
if(!isset($_POST["submit"]) || empty(basename($_FILES["uploaded_file"]["name"]))) {
|
||||
$upload_msg = "No file submitted.";
|
||||
$upload_ok = 0;
|
||||
} elseif (file_exists($target_file)) {
|
||||
|
@ -26,8 +26,8 @@ if ($upload_ok == 0) {
|
|||
|
||||
// if everything is ok, try to upload file
|
||||
} else {
|
||||
if (move_uploaded_file($_FILES["hw_submission"]["tmp_name"], $target_file)) {
|
||||
$upload_msg = "😊 ✅ Your homework file ". htmlspecialchars( basename( $_FILES["hw_submission"]["name"])). " was successfully uploaded!";
|
||||
if (move_uploaded_file($_FILES["uploaded_file"]["tmp_name"], $target_file)) {
|
||||
$upload_msg = "😊 ✅ Your file <span style=\"font-weight:bold; font-style:italic;\">". htmlspecialchars( basename( $_FILES["uploaded_file"]["name"])). "</span> was successfully uploaded!";
|
||||
} else {
|
||||
$upload_msg = "❌ There was an error uploading your file. " . $upload_msg;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ $file_count = getFileCount($target_folder_path)
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<title>IIAB Homework Submission App</title>
|
||||
<title>IIAB Upload to USB App</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
|
@ -57,9 +57,9 @@ $file_count = getFileCount($target_folder_path)
|
|||
<div class="col-sm-6 offset-sm-3 text-center" style="padding:15px;">
|
||||
|
||||
<img class="mb-4" src="unleash-kids-swing.png" alt="" width="75">
|
||||
<h1 class="h3 mb-3 font-weight-normal">Internet in a Box Homework Submission</h1>
|
||||
<h1 class="h3 mb-3 font-weight-normal">Internet in a Box Upload to USB</h1>
|
||||
<?php echo $upload_msg ?> <br/>
|
||||
<?php echo $file_count ?> homework files have been submitted today!
|
||||
<?php echo $file_count ?> files have been submitted today!
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -16,19 +16,14 @@ function getTargetUSBDriveLocation () {
|
|||
if (empty($removable_usb_path)) {
|
||||
return "/library/www/html/local_content/";
|
||||
} else {
|
||||
|
||||
return $removable_usb_path . "/";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//returns folder path where homework will be stored, if create_folder_p = 1, it will create the folder if it doesn't exist
|
||||
//returns folder path where file will be stored, if create_folder_p = 1, it will create the folder if it doesn't exist
|
||||
function getTargetFolderPath ($create_folder_p) {
|
||||
$parent_dir = getTargetUSBDriveLocation();
|
||||
|
||||
|
||||
error_log("PARENTDIR: " . $parent_dir);
|
||||
|
||||
// error_log("PARENTDIR: " . $parent_dir);
|
||||
$today_folder_name = "UPLOADS." . date("Y-m-d");
|
||||
$target_folder_path = $parent_dir . $today_folder_name;
|
||||
|
||||
|
@ -36,9 +31,7 @@ error_log("PARENTDIR: " . $parent_dir);
|
|||
mkdir($target_folder_path, 0777);
|
||||
|
||||
}
|
||||
|
||||
return $target_folder_path;
|
||||
|
||||
}
|
||||
|
||||
//return number of files within a specified folder
|
||||
|
@ -48,19 +41,16 @@ function getFileCount ($folder_path) {
|
|||
|
||||
//*** TODO *** check file content to see if it's unique or not
|
||||
function isFileContentUnique ($file) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//*** TODO **** check if file exists based on file name and return unique name if does
|
||||
function getUniqueFileName ($filename) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Check file size - we are not going to check file size for now.
|
||||
// elseif ($_FILES["hw_submission"]["size"] > 5000000) {
|
||||
// elseif ($_FILES["uploaded_file"]["size"] > 5000000) {
|
||||
// $upload_msg = "Your file is too large.";
|
||||
// $upload_ok = 0;
|
||||
// }
|
||||
|
|
Loading…
Add table
Reference in a new issue