3

To be brief;

php unlink is working with files if their name is asci. However unlink produce file not found error if i try to delete a file with a name including ç ö etc.

Is there any way that i can fix this? Or is it a problem caused by the relation between PHP & Operating System.

user2102266
  • 539
  • 3
  • 14

1 Answers1

2

It is definitive an encoding problem.

Try this (if './çö' isn't UTF-8, dynamicly loaded for example):

unlink(mb_convert_encoding('./çö', 'UTF-8'))

Maybe you are using Windows? From here:

unlink(iconv('utf-8', 'cp1252', './çö'));

Anyway: You should avoid those filenames. If it comes from user: NEVER TRUST USER INPUT!

Community
  • 1
  • 1
Christian Gollhardt
  • 16,510
  • 17
  • 74
  • 111
  • so i should read and write file names according to the os. .I should convert bin data to encoded strings with using code page conversions ? – user2102266 Aug 28 '14 at 00:30
  • @user2102266 Never has seen UTF-8 Symbols in Filenames. You should avoid it. Not understand what you mean with the second part. – Christian Gollhardt Aug 28 '14 at 00:35
  • yup both are working. `unlink(mb_convert_encoding('./çö', 'UTF-8'))` for lamp. `unlink(iconv('utf-8', 'cp1252', './çö'));` for wamp. thanks – user2102266 Aug 29 '14 at 04:34