作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
如何使用 PHP 将远程文件从链接(例如 http://site.com/file.zip
)上传到 FTP 服务器?我想将“Vanilla Forum Software”上传到服务器,而我的移动数据运营商收费很高,所以如果我可以上传文件而不必从我的手机上传它,我也可以省钱并完成工作。
最佳答案
让你拥有这个功能:
function downloadfile($file, $path) {
if(isset($file) && isset($path)) {
$fc = implode('', file($file));
$fp = explode('/', $file);
$fn = $fp[count($fp) - 1];
if(file_exists($path . $fn)) {
$Files = fopen($path . $fn, 'w');
} else {
$Files = fopen($path . $fn, 'x+');
}
$Writes = fwrite($Files, $fc);
if ($Writes != 0){
echo 'Saved at ' . $path . $fn . '.';
fclose($Files);
}
else{
echo 'Error.';
}
}
}
你可以这样使用它:
downloadfile("http://www.webforless.dk/logo.png","folder/");
希望它运作良好,记得 Chmod 目标文件夹 777。((如果你需要它上传到另一个 FTP 服务器,你可以使用其他评论中发布的 FTP 脚本之一))
最好的问候。乔纳斯
关于php - 使用 PHP 从远程服务器上传文件到 FTP 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8149801/
我有以下正则表达式 /[a-zA-Z0-9_-]/ 当字符串只包含从 a 到z 大小写、数字、_ 和 -。 我的代码有什么问题? 能否请您向我提供一个简短的解释和有关如何修复它的代码示例? //var
我是一名优秀的程序员,十分优秀!