Şuanki Dizin: /home/wwwdreamtechnolo/public_html/bprisk.online/strongergenadmin/ |
Şuanki Dosya : /home/wwwdreamtechnolo/public_html/bprisk.online/strongergenadmin/file_upload.php |
<?php if(isset($_POST['submit_btn'])) { $path = "documents/"; //Valid formats for file upload $valid_formats = array("jpg", "png", "gif", "bmp", "JPG", "PNG", "GIF", "BMP"); function generateRandomString($length = 15) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST") { $name = $_FILES['upload_file']['name']; $size = $_FILES['upload_file']['size']; if(strlen($name)) { //abc.png list($txt, $ext) = explode(".", $name); if(in_array($ext,$valid_formats)) { if($_FILES['upload_file']['size'] < 10485760) //10MB File size { $files = array(); $current_random_no = generateRandomString(); //abcdfrhfj5.png $actual_image_name = $current_random_no.".".strtolower($ext); $tmp = $_FILES['upload_file']['tmp_name']; if(move_uploaded_file($tmp, $path.$actual_image_name)) { echo "File Upload Success"; $success_msg = 1; } else { $error_message = "failed"; } } else { $error_message = "File size exceeded"; } } else { $error_message = "Invalid file format."; } } else{ echo "No file selected"; } } } ?> <html> <head></head> <body> <form action="file_upload.php" method="POST" enctype="multipart/form-data"> <input type="file" name="upload_file" /> <input type="submit" name="submit_btn" /> </form> </body> </html>
Linux 65-254-81-4.cprapid.com 5.14.0-284.11.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 9 05:49:00 EDT 2023 x86_64
Apache
65.254.81.4