4

i want to rename file in php when file name is persian(farsi/arabic).

file name: 'ش' and i want to rename 'a'

and this code not work:

rename("ش", "a");

result:

Warning: rename(ش,a): The system cannot find the file specified. (code: 2) in C:\xampp_new\htdocs\vira2\test.php on line 5

PHP Version 5.6.3 on Xampp on Windows

Ali Mohammadi
  • 1,306
  • 1
  • 14
  • 28
  • check this thread, maybe that can help : http://stackoverflow.com/questions/11243863/php-rename-faled-for-filename-with-utf-8-arabic-charset-string – Yacino May 09 '15 at 22:18
  • I checked before. but not work. this answer use by linux bash commands. – Ali Mohammadi May 09 '15 at 22:20

2 Answers2

1

Edit:

<?php
  setlocale(LC_ALL, 'ar');
  mkdir('ش');
  rename('ش', 'a');
Ben
  • 1,557
  • 13
  • 30
0

You have to include the path of the file.

<?php

rename("c\ش", "c\a"); ?>

Mathieu
  • 38
  • 7