Fix client file upload not automatically naming files or showing image previews
This commit is contained in:
@@ -7044,12 +7044,20 @@ if(isset($_POST['add_file'])){
|
||||
$client_id = intval($_POST['client_id']);
|
||||
$file_name = sanitizeInput($_POST['new_name']);
|
||||
|
||||
if(!file_exists("uploads/clients/$client_id")) {
|
||||
$extarr = explode('.', $_FILES['file']['name']);
|
||||
$file_extension = sanitizeInput(strtolower(end($extarr)));
|
||||
|
||||
// If the user-inputted name is empty, revert to the name of the file on disk/uploaded
|
||||
if (empty($file_name)) {
|
||||
$file_name = sanitizeInput($_FILES['file']['name']);
|
||||
}
|
||||
|
||||
if (!file_exists("uploads/clients/$client_id")) {
|
||||
mkdir("uploads/clients/$client_id");
|
||||
}
|
||||
|
||||
//Check to see if a file is attached
|
||||
if($_FILES['file']['tmp_name'] != ''){
|
||||
if ($_FILES['file']['tmp_name'] != '') {
|
||||
|
||||
if ($file_reference_name = checkFileUpload($_FILES['file'], array('jpg', 'jpeg', 'gif', 'png', 'webp', 'pdf', 'txt', 'md', 'doc', 'docx', 'csv', 'xls', 'xlsx', 'xlsm', 'zip', 'tar', 'gz'))) {
|
||||
|
||||
@@ -7064,7 +7072,7 @@ if(isset($_POST['add_file'])){
|
||||
mysqli_query($mysqli,"INSERT INTO files SET file_reference_name = '$file_reference_name', file_name = '$file_name', file_ext = '$file_extension', file_client_id = $client_id");
|
||||
|
||||
$_SESSION['alert_message'] = 'File successfully uploaded.';
|
||||
}else{
|
||||
} else {
|
||||
|
||||
$_SESSION['alert_message'] = 'There was an error moving the file to upload directory. Please make sure the upload directory is writable by web server.';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user