簡體   English   中英

想要從服務器下載圖像

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM