我想通过使用file_get_content()
从REST API获取一个映像并存储在Symfony2中。$image = file_get_contents('https://foobar, false, $context)
但是,当我试图清理文件时,我会遇到麻烦。
$image->move($app['config']['image_temp_realdir'], $filename);
这一行导致"错误:调用字符串上的成员函数move((">
我知道此文件数据不是文件实体,但如何将其转换为文件实体?或者我可以使用任何方法来获取文件而不是file_get_content()
?
提前感谢您的帮助。
对不起,问题解决了。
file_put_contents()
保存文件并创建新文件。
file_put_contents($app['config']['image_temp_realdir'].'/'.$filename, $image);
$file = new File($app['config']['image_temp_realdir'].'/'.$filename);