简体   繁体   中英

php copy not working with utf8 characters?

I am using php copy() function and am getting strange results which made me google and couldn't find anything about this topic so my conclusion was that php's copy($src, $dest) function cant have utf8 characters in the $src and $dest, but just wanted you guys to confirm on this - or maybe you know a way around this?

final conclusion: @azat: I thank you for your answers and trying to help - but all in all now I see I was wrong! The files (when downloaded to my computer did have correct caracters!, but when I was viewing the contents of the folder from my WinSCP I was seeing them all scrambled which I presume is because of the WinSCP. Anyway I will mark your answer correct as you were the only one to help and made me realize my error in the end.

edit: system on which i run this is Linux and an example of the command in php file is this:

<?php
    copy ("images/test.png", "images/myTestŽĆČĐŠžćčđš.png");
?>

edit2:

#>uname -a
Linux litij.avalon.hr 2.6.18-274.3.1.el5 #1 SMP Tue Sep 6 20:13:52 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux

#>cat /etc/mtab
/dev/root /lib virtfs defaults 0 0
/dev/root /opt virtfs defaults 0 0
/dev/root /lib64 virtfs defaults 0 0
/dev/root /usr/lib virtfs defaults 0 0
/dev/root /usr/lib64 virtfs defaults 0 0
/dev/root /usr/sbin virtfs defaults 0 0
/dev/root /usr/share virtfs defaults 0 0
/dev/root /usr/bin virtfs defaults 0 0
/dev/root /usr/man virtfs defaults 0 0
/dev/root /usr/X11R6 virtfs defaults 0 0
/dev/root /usr/kerberos virtfs defaults 0 0
/dev/root /usr/libexec virtfs defaults 0 0
/dev/root /usr/local/bin virtfs defaults 0 0
/dev/root /usr/local/share virtfs defaults 0 0
/dev/root /usr/local/Zend virtfs defaults 0 0
/dev/root /usr/local/IonCube virtfs defaults 0 0
/dev/root /usr/include virtfs defaults 0 0
/dev/root /usr/local/lib virtfs defaults 0 0
/dev/root /var/spool virtfs defaults 0 0
/dev/root /var/lib virtfs defaults 0 0
/dev/root /var/cpanel virtfs defaults 0 0
/dev/root /usr/local/cpanel/Cpanel virtfs defaults 0 0
/dev/root /var/run virtfs defaults 0 0
/dev/root /var/log virtfs defaults 0 0
/dev/root /tmp virtfs defaults 0 0
/dev/root /dev virtfs defaults 0 0
/dev/root /bin virtfs defaults 0 0
/dev/root /usr/local/apache/domlogs virtfs defaults 0 0
/dev/root /etc/mail virtfs defaults 0 0
/dev/root /home/fotoctim virtfs defaults 0 0
none /proc proc rw 0 0

Worth noting is that my copy command doesn't give any errors :(

if (copy($src, $dest)){
    echo  "File <b>successfully</b> copied to $dest<br/>";
}
else{
    echo "File <b>was not!</b> copied to $dest<br/>";
}

Ext4
LANG=en_US.UTF-8

<?
touch("/tmp/test.png");
copy("/tmp/test.png", "/tmp/myTestŽĆČĐŠžćčđš.png");
azat:~$ ls /tmp/myTestŽĆČĐŠžćčđš.png 
/tmp/myTestŽĆČĐŠžćčđš.png

So the question is what filesystem you have and mount options

I know this is late, but you need to check that the format of the php file containing the copy script below is utf-8 format. so when it copies the file, it copies it in the same format. this is how i solved my problem.

<?php

copy($path,$dest); ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM