0

I need my webapp to create a file on the server from another server. Input parameter is URL of a remote file. I stumbled upon cURL wrapper for Yii. Is it right tool for my task?

4

1 回答 1

0

我找到了解决方案。不需要第三方模块。这是一个草稿版本:

<?php
$f1 = fopen($_REQUEST['pic_url'],'r');
$fcontent = $contents = stream_get_contents($f1);
fclose($f1);

$fileName = microtime().'.'.CFileHelper::getExtension($_REQUEST['pic_url']);

$f2 = fopen(Yii::app()->basePath.'/../images/'.$fileName,'c+');
fwrite($f2,$fcontent,strlen($fcontent));
fclose($f2);
?>

基本上,这段代码读取远程服务器上的图像并将其保存在家庭服务器上。

于 2013-08-01T02:08:37.407 回答