2
我一直在寻找一种将相对路径放入到file_put_content()
函数中的方法。基本上我想复制一个文件到我的服务器的目录之一。这里是我迄今所做的:在CakePHP的file_put_content()中指定相对路径服务器
function curl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$image_new = curl($image);
file_put_contents("/minimaled_server_path/app/webroot/logo_url",
$image_new);
它扔我的错误如下:
file_put_contents(/minimal_server_path/app/webroot/logo_url)
[function.file-put-contents]:
failed to open stream: No such file or directory
[APP/Controller/AppsController.php, line 105]
缺少什么我在这里?
尝试从文件路径除去最主要的斜线。相对路径不以斜杠开始,绝对路径。另外,考虑使用'fopen()'并将句柄传递给'CURLOPT_FILE',它会更有效率。 – DaveRandom 2012-08-01 10:07:10
我已经改变了我的代码,正如你所说的。但仍然没有得到解决 – 2012-08-01 10:10:22
还是一样的错误?试试'echo getcwd();'以确保你在你认为你的目录中工作。 – DaveRandom 2012-08-01 10:11:23