Server IP : 162.240.98.243 / Your IP : 3.149.233.43 Web Server : Apache System : Linux server.bti.yaw.mybluehostin.me 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : btiyawmy ( 1003) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/btiyawmy/public_html/login.easenup.in/ |
Upload File : |
<?php // Include the database configuration file include_once 'dbconnection.php'; if(isset($_POST['submit'])){ // File upload configuration $targetDir = "uploads/"; $allowTypes = array('jpg','png','jpeg','gif'); $statusMsg = $errorMsg = $insertValuesSQL = $errorUpload = $errorUploadType = ''; $fileNames = array_filter($_Evidence['Evidence']['name']); if(!empty($fileNames)){ foreach($_Evidence['Evidence']['name'] as $key=>$val){ // File upload path $fileName = basename($_Evidence['Evidence']['name'][$key]); $targetFilePath = $targetDir . $fileName; // Check whether file type is valid $fileType = pathinfo($targetFilePath, PATHINFO_EXTENSION); if(in_array($fileType, $allowTypes)){ // Upload file to server if(move_uploaded_file($_Evidence["Evidence"]["tmp_name"][$key], $targetFilePath)){ // Image db insert sql $insertValuesSQL .= "('".$fileName."', NOW()),"; }else{ $errorUpload .= $_Evidence['Evidence']['name'][$key].' | '; } }else{ $errorUploadType .= $_Evidence['Evidence']['name'][$key].' | '; } } // Error message $errorUpload = !empty($errorUpload)?'Upload Error: '.trim($errorUpload, ' | '):''; $errorUploadType = !empty($errorUploadType)?'File Type Error: '.trim($errorUploadType, ' | '):''; $errorMsg = !empty($errorUpload)?'<br/>'.$errorUpload.'<br/>'.$errorUploadType:'<br/>'.$errorUploadType; if(!empty($insertValuesSQL)){ $insertValuesSQL = trim($insertValuesSQL, ','); // Insert image file name into database $insert = $db->query("UPDATE investigation SET(file_name) VALUES $insertValuesSQL WHERE id='$_GET[id]'"); if($insert){ $statusMsg = "Evidence are uploaded successfully.".$errorMsg; }else{ $statusMsg = "Sorry, there was an error uploading your file."; } }else{ $statusMsg = "Upload failed! ".$errorMsg; } }else{ $statusMsg = 'Please select a file to upload.'; } } ?>