Home > Backend Development > PHP Problem > What to do if php copy fails

What to do if php copy fails

藏色散人
Release: 2023-03-03 21:34:02
Original
4138 people have browsed it

Solution to php copy failure: First get the absolute path of the file to be copied; then copy the file to a path somewhere; then convert the character encoding through the iconv function; finally use copy to copy.

What to do if php copy fails

Recommended: "PHP Video Tutorial"

Solution to PHP copy Chinese name file failure

When copying a file, if the file path contains a Chinese name. Or if the copied file name has Chinese characters, an error will be reported

Solution

$source="./upload/测试.png";//要复制的文件的 绝对路径(服务器上的)
$dest="./ipload/image/复制后.png";//将文件复制到某处的路径
$source = iconv('utf-8', 'gbk', $source);//使用后可以复制了
$dest = iconv('utf-8', 'gbk', $dest);//使用后可以复制了
if(copy($source,$dest)){
   echo “成功”;
}
Copy after login

The above is the detailed content of What to do if php copy fails. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template