2025-01-05 21:35:38 +00:00
< ? php
/*
* upload - file . php
* Upload2USB App - Process Submission
*/
2025-01-17 08:34:15 +00:00
$title = " Upload to USB Results " ;
2025-01-12 11:04:47 +00:00
include ( " header.php " );
2025-01-05 21:35:38 +00:00
2025-01-06 03:48:19 +00:00
//get folder path where file will be stored
2025-01-05 21:35:38 +00:00
$target_folder_path = getTargetFolderPath ( 1 );
2025-01-12 11:04:47 +00:00
$uploaded_filename = basename ( $_FILES [ " uploaded_file " ][ " name " ]);
$target_file = $target_folder_path . " / " . $uploaded_filename ;
2025-01-05 21:35:38 +00:00
$upload_ok = 1 ;
$upload_msg = " " ;
2025-01-12 11:04:47 +00:00
if ( ! isset ( $_POST [ " submit " ]) || ! is_uploaded_file ( $_FILES [ 'uploaded_file' ][ 'tmp_name' ])) {
2025-01-23 05:19:13 +00:00
$upload_msg = " No file uploaded! " ;
2025-01-12 11:04:47 +00:00
$upload_ok = 0 ;
} elseif ( ! isFileMimeTypeAcceptable ( $_FILES [ " uploaded_file " ][ " tmp_name " ])) {
2025-01-23 05:19:13 +00:00
$upload_msg = " You cannot upload zips, executables, xml, or binary files! " ;
2025-01-12 11:04:47 +00:00
$upload_ok = 0 ;
2025-01-05 21:35:38 +00:00
} elseif ( file_exists ( $target_file )) {
2025-01-19 07:21:27 +00:00
if ( ! isFileContentUnique ( $target_folder_path , $_FILES [ " uploaded_file " ][ " tmp_name " ])) {
$upload_msg = " This file already exists! " ;
$upload_ok = 0 ;
} else {
// rename file so name is unique
$new_filename = getUniqueFileName ( $target_folder_path , $uploaded_filename );
$target_file = $target_folder_path . " / " . $new_filename ;
}
}
2025-01-17 22:03:01 +00:00
2025-01-05 21:35:38 +00:00
// Check if $upload_ok is set to 0 by an error
if ( $upload_ok == 0 ) {
$upload_msg = " ❌ Your file was not uploaded. " . $upload_msg ;
// if everything is ok, try to upload file
} else {
2025-01-06 03:48:19 +00:00
if ( move_uploaded_file ( $_FILES [ " uploaded_file " ][ " tmp_name " ], $target_file )) {
2025-01-12 11:04:47 +00:00
$upload_msg = " 😊 ✅ Your file <span style= \" font-weight:bold; font-style:italic; \" > " . htmlspecialchars ( $uploaded_filename ) . " </span> was successfully uploaded! " ;
2025-01-05 21:35:38 +00:00
} else {
2025-01-12 11:04:47 +00:00
$upload_msg = " ❌ There was an error uploading your file. " . $_FILES [ " upload_file " ][ " error " ] . $upload_msg ;
2025-01-05 21:35:38 +00:00
}
}
2025-01-12 11:04:47 +00:00
$file_count = getFileCount ( $target_folder_path );
2025-01-05 21:35:38 +00:00
?>
< ? php echo $upload_msg ?> <br/>
2025-01-23 05:19:13 +00:00
< ? php echo $file_count ?> files have been uploaded today!
2025-01-05 21:35:38 +00:00
2025-01-12 11:04:47 +00:00
< ? php include ( " footer.php " ); ?>
2025-01-05 21:35:38 +00:00