PHP : get file contents and store file in particular folder

标签 php file

我从 php 中的 file_get_contents() 函数获取文件内容,我想将该文件存储在特定文件夹中。我该怎么做?

$image = file_get_contents('http://www.affiliatewindow.com/logos/1961/logo.gif');

我想将此图像保存在特定文件夹中。

有什么想法吗?

最佳答案

使用 file_put_contents()

$image = file_get_contents('http://www.affiliatewindow.com/logos/1961/logo.gif');
file_put_contents('./myDir/myFile.gif', $image);

关于PHP : get file contents and store file in particular folder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2729143/

相关文章:

php - 在 MySQL PHP 中更新查询

php - PHP 中的广度优先搜索

javascript - 读取变量中上传的文本文件内容

c - 如何比较文件中的字符串和标准输入字符串

c# - 从 DirectoryInfo.GetFiles 返回的 FileInfo 没有指向文件?

c - 在 C 中另存为二进制文件,但不显示零和一

c - 从 C 中的文件读取时忽略\n?

php - 如何交叉选择一些数据

javascript - 如何在AJAX中同时访问JSON对象、二维和单个数组?

java - Java 中 PHP 的 crypt 函数的等价物