[英]want to download images from server
我想将站点从共享主机服务器转移到专用服务器。当前服务器有文件夹,其中包括大约。 16000张图片...我们不能使用FTP下载这么多图片。我没有SSH权限? 我如何从该共享托管服务器下载图像。
我们不能使用FTP下载这么多图像
废话。 FTP(协议)完全可以下载16000个文件。 如果您的FTP程序给您带来麻烦,只需选择一个更好的FTP程序。 如果可以处理命令行应用程序,则wget
很不错,因为它支持递归和继续。
除非它们位于Web应用程序服务器的Web根目录内的目录中,否则您很不幸。
全部压缩,改编自http://davidwalsh.name/create-zip-php
<?php
function create_zip($files = array(),$destination = '',$overwrite = false) {
//if the zip file already exists and overwrite is false, return false
if(file_exists($destination) && !$overwrite) { return false; }
//vars
$valid_files = array();
//if files were passed in...
if(is_array($files)) {
//cycle through each file
foreach($files as $file) {
//make sure the file exists
if(file_exists($file)) {
$valid_files[] = $file;
}
}
}
//if we have good files...
if(count($valid_files)) {
//create the archive
$zip = new ZipArchive();
if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
return false;
}
//add the files
foreach($valid_files as $file) {
$zip->addFile($file,$file);
}
//debug
//echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status;
//close the zip -- done!
$zip->close();
//check to make sure the file exists
return file_exists($destination);
}
else
{
return false;
}
}
//glob images folder into an array
foreach (glob("*.jpg") as $filename) {
$files_to_zip[]='images/'.$filename;
}
//create the zip
$result = create_zip($files_to_zip,'my-images.zip');
if($result==true){echo'<a href="my-images.zip">Download Images</a>';
}else{
echo'Could not create zip';}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.