So I am using a raspberry pi and want to use it as a place where I can upload and download any kind of file with any kind of extension.
Here is my code
<!DOCTYPE html>
<html>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
    <input type="file" name="file">
    <input type="submit" value="upload">
</form>
<?php  
if(isset($_FILES['file'])) {
    $file = $_FILES['file'];
    $file_name = $file['name'];
    $file_tmp = $file['tmp_name'];
    $file_size = $file['size'];
    $file_error = $file['error'];
    $file_ext = explode('.', $file_name);
    $file_ext = strtolower(end($file_ext));
    $allowed = array('txt', 'jpg');
    if(in_array($file_ext, $allowed)) {
        if($file_error === 0) {
            if($file_size <= 1073741824) {
                $file_name_new = uniqid('', true) . '.' . $file_ext;
                $file_destination = './files/' . $file_name_new;
                if(move_uploaded_file($file_tmp, $file_destination)) {
                    echo $file_destination;
                }
            }
        }
    }
}
?>
</body>
</html>
It works great but when the file uploaded i got random file name not the original name How i can keep the original filename uploaded not a random name !
 
     
    