PHP复制功能不工作 [英] PHP Copy function not working

查看:157
本文介绍了PHP复制功能不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用php中的复制功能将图像从网址复制到我的服务器。

该函数打开服务器上的正确文件夹,但该文件不在最后一个文件夹中。它只是空的。

I'm trying to use copy function in php to copy an image from a url to my server.
The function opens the right folders on the server but the file is not in the last folder. its just empty.

这是我的代码:

$srcfile="http://domain.com/images2/2014/01/02/1.jpg";
$dstfile="/images/2014/01/02/1.jpg";
mkdir(dirname($dstfile), 0777, true);
copy($srcfile, $dstfile);

任何想法为什么会这样?

任何帮助将非常感激。

Any idea on why could this be?
Any help would be highly appreciated.

推荐答案

尝试:

$srcfile="http://domain.com/images2/2014/01/02/1.jpg";
$dstfile=$_SERVER['DOCUMENT_ROOT'] . "/images/2014/01/02/1.jpg";
mkdir(dirname($dstfile), 0777, true);
copy($srcfile, $dstfile);

这篇关于PHP复制功能不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆