Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating arabic folder using php

I want to create Arabic folders or files using PHP but I always receive strange letters when using this code `

$location  = "d:/test" ; // Your Location 

$foldername = "عربى" ; // Your Folder Name 

$path = $location . "/" . $foldername ;



if (!is_dir ( $path )) { 

    if(is_writable($location)) 
    { 
        echo $path."<br>"; 
        mkdir ($path, 0777 ); 
    } 
    else 
    { 
        die("You don't have permission to create folder"); 
    } 
} 
like image 971
Hussein Sayed Avatar asked Dec 01 '25 12:12

Hussein Sayed


1 Answers

Link from Álvaro G. Vicario in comment under your question says that is impossible in PHP. I think it may be possible in Microsoft ASP.NET, but im not sure. If this is very important to you - you can make some research about it and maybe switch from PHP to ASP.

Anyway, in PHP you can use urlencode and urldecode functions to store and get non-latin characters in diffrent way. In fact - folder will get weird name (under operating system you will see something like this: %51%%32%%DA%), but you can decode it back into original characters to display them on website.

Here is more information (read best answer):

How do I use filesystem functions in PHP, using UTF-8 strings?

like image 191
Kamil Avatar answered Dec 03 '25 04:12

Kamil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!