Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

move_uploaded_file function in PHP

Tags:

php

I have a problem that I'm using move_uploaded_file() function to upload files and some of the files named in Arabic so I googled the problem but still no answer I used meta tag and I used Base64 encode and everything but still doesn't work. What is the solution ?

<?php
    $data_name=$_POST['name'];
    $name=base64_encode($_FILES['file']['name']);
    $location="../Files/".$course_name."/";
    $tmp_name=$_FILES['file']['tmp_name'];
    if(move_uploaded_file($tmp_name, $location.$name))
        echo"OK";
?>
like image 305
Montaser Qasem Avatar asked Oct 31 '22 12:10

Montaser Qasem


1 Answers

One solution can be:

Have a database where save your arabic name of file and give that file some custom unique name with current time, also save custom name into db, at time of retreival change file name and show to user.

OR use some name conversion library which convert text from arabic to englidh and vice versa. for this purpose have a look on these refferences

how to convert english into arabic dynamically

convert Persian/Arabic numbers to English numbers

OR convert string into utf-8 using php for help:

PHP: Convert any string to UTF-8 without knowing the original character set, or at least try

http://php.net/manual/en/function.utf8-encode.php

like image 50
Imran Qamer Avatar answered Nov 04 '22 10:11

Imran Qamer