Move_uploaded_file function in PHP

I have a problem with the fact that I use the move_uploaded_file() function to upload files and some files named in Arabic, so I searched for this problem but still haven't answered. I used the meta tag and I used Base64 encoding and everything else. Don'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"; ?> 
+5
source share
1 answer

One solution could be:

Have a database in which you save your Arabic file name and give this file some custom unique name with the current time, also save your own name in db, while changing the file name changes and show the user.

OR use some name conversion library that converts text from Arabic to englidh and vice versa. for this take a look at these references

how to convert english to arabic dynamically

convert persian / arabic numbers to english numbers

OR convert string to utf-8 using php for reference:

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

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

+2
source

Source: https://habr.com/ru/post/1239362/


All Articles