<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # FTP 類 CodeIgniter 的 FTP 類允許你傳輸文件至遠程服務器,也可以對遠程文件進行移動、重命名或刪除操作。 FTP 類還提供了一個 "鏡像" 功能,允許你將你本地的一個目錄通過 FTP 整個的同步到遠程服務器上。 注解 只支持標準的 FTP 協議,不支持 SFTP 和 SSL FTP 。 [TOC=2,3] ## 使用 FTP 類 ### 初始化類 正如 CodeIgniter 中的其他類一樣,在你的控制器中使用?$this->load->library()?方法來初始化 FTP 類: ~~~ $this->load->library('ftp'); ~~~ 初始化之后,FTP 類的對象就可以這樣訪問: ~~~ $this->ftp ~~~ ### 使用示例 在這個例子中,首先建立一個到 FTP 服務器的連接,接著讀取一個本地文件然后以 ASCII 模式上傳到服務器上。文件的權限被設置為 755 。 ~~~ $this->load->library('ftp'); $config['hostname'] = 'ftp.example.com'; $config['username'] = 'your-username'; $config['password'] = 'your-password'; $config['debug'] = TRUE; $this->ftp->connect($config); $this->ftp->upload('/local/path/to/myfile.html', '/public_html/myfile.html', 'ascii', 0775); $this->ftp->close(); ~~~ 下面的例子從 FTP 服務器上獲取文件列表。 ~~~ $this->load->library('ftp'); $config['hostname'] = 'ftp.example.com'; $config['username'] = 'your-username'; $config['password'] = 'your-password'; $config['debug'] = TRUE; $this->ftp->connect($config); $list = $this->ftp->list_files('/public_html/'); print_r($list); $this->ftp->close(); ~~~ 下面的例子在 FTP 服務器上創建了一個本地目錄的鏡像。 ~~~ $this->load->library('ftp'); $config['hostname'] = 'ftp.example.com'; $config['username'] = 'your-username'; $config['password'] = 'your-password'; $config['debug'] = TRUE; $this->ftp->connect($config); $this->ftp->mirror('/path/to/myfolder/', '/public_html/myfolder/'); $this->ftp->close(); ~~~ ## 類參考 classCI_FTP >[info] ### connect([$config = array()]) 參數: * **$config**?(array) -- Connection values 返回: TRUE on success, FALSE on failure 返回類型: bool 連接并登錄到 FTP 服務器,通過向函數傳遞一個數組來設置連接參數,或者你可以把這些參數保存在一個配置文件中。 下面例子演示了如何手動設置參數: ~~~ $this->load->library('ftp'); $config['hostname'] = 'ftp.example.com'; $config['username'] = 'your-username'; $config['password'] = 'your-password'; $config['port'] = 21; $config['passive'] = FALSE; $config['debug'] = TRUE; $this->ftp->connect($config); ~~~ **在配置文件中設置 FTP 參數** 如果你喜歡,你可以把 FTP 參數保存在一個配置文件中,只需創建一個名為 ftp.php 的文件, 然后把 $config 數組添加到該文件中,然后將文件保存到?application/config/ftp.php?, 它就會自動被讀取。 **可用的連接選項** | 選項名稱 | 默認值 | 描述 | | --- | --- | --- | | **hostname** | n/a | FTP 主機名(通常類似于這樣:ftp.example.com) | | **username** | n/a | FTP 用戶名 | | **password** | n/a | FTP 密碼 | | **port** | 21 | FTP 服務端口 | | **debug** | FALSE | TRUE/FALSE (boolean): 是否開啟調試模式,顯示錯誤信息 | | **passive** | TRUE | TRUE/FALSE (boolean): 是否使用被動模式 | >[info] ### upload($locpath,?$rempath[,?$mode = 'auto'[,?$permissions = NULL]]) 參數: * **$locpath**?(string) -- Local file path * **$rempath**?(string) -- Remote file path * **$mode**?(string) -- FTP mode, defaults to 'auto' (options are: 'auto', 'binary', 'ascii') * **$permissions**?(int) -- File permissions (octal) 返回: TRUE on success, FALSE on failure 返回類型: bool 將一個文件上傳到你的服務器上。必須指定本地路徑和遠程路徑這兩個參數,而傳輸模式和權限設置這兩個參數則是可選的。例如: > $this->ftp->upload('/local/path/to/myfile.html', '/public_html/myfile.html', 'ascii', 0775); 如果使用了 auto 模式,將根據源文件的擴展名來自動選擇傳輸模式。 設置權限必須使用一個 八進制 的權限值。 >[info] ### download($rempath,?$locpath[,?$mode = 'auto']) 參數: * **$rempath**?(string) -- Remote file path * **$locpath**?(string) -- Local file path * **$mode**?(string) -- FTP mode, defaults to 'auto' (options are: 'auto', 'binary', 'ascii') 返回: TRUE on success, FALSE on failure 返回類型: bool 從你的服務器下載一個文件。必須指定遠程路徑和本地路徑,傳輸模式是可選的。例如: > $this->ftp->download('/public_html/myfile.html', '/local/path/to/myfile.html', 'ascii'); 如果使用了 auto 模式,將根據源文件的擴展名來自動選擇傳輸模式。 如果下載失敗(包括 PHP 沒有寫入本地文件的權限)函數將返回 FALSE 。 >[info] ### rename($old_file,?$new_file[,?$move = FALSE]) 參數: * **$old_file**?(string) -- Old file name * **$new_file**?(string) -- New file name * **$move**?(bool) -- Whether a move is being performed 返回: TRUE on success, FALSE on failure 返回類型: bool 允許你重命名一個文件。需要指定原文件的文件路徑和名稱,以及新的文件路徑和名稱。 ~~~ // Renames green.html to blue.html $this->ftp->rename('/public_html/foo/green.html', '/public_html/foo/blue.html'); ~~~ >[info] ### move($old_file,?$new_file) 參數: * **$old_file**?(string) -- Old file name * **$new_file**?(string) -- New file name 返回: TRUE on success, FALSE on failure 返回類型: bool 允許你移動一個文件。需要指定原路徑和目的路徑: ~~~ // Moves blog.html from "joe" to "fred" $this->ftp->move('/public_html/joe/blog.html', '/public_html/fred/blog.html'); ~~~ > 注解 > 如果目的文件名和原文件名不同,文件將會被重命名。 >[info] ### delete_file($filepath) 參數: * **$filepath**?(string) -- Path to file to delete 返回: TRUE on success, FALSE on failure 返回類型: bool 用于刪除一個文件。需要提供原文件的路徑。 ~~~ $this->ftp->delete_file('/public_html/joe/blog.html'); ~~~ >[info] ### delete_dir($filepath) 參數: * **$filepath**?(string) -- Path to directory to delete 返回: TRUE on success, FALSE on failure 返回類型: bool 用于刪除一個目錄以及該目錄下的所有文件。需要提供目錄的路徑(以斜線結尾)。 >[danger] 重要 > 使用該方法要非常小心! 它會遞歸的刪除目錄下的所有內容,包括子目錄和所有文件。請確保你提供的路徑是正確的。 你可以先使用list_files()?方法來驗證下路徑是否正確。 ~~~ $this->ftp->delete_dir('/public_html/path/to/folder/'); ~~~ >[info] ### list_files([$path = '.']) 參數: * **$path**?(string) -- Directory path 返回: An array list of files or FALSE on failure 返回類型: array 用于獲取服務器上某個目錄的文件列表,你需要指定目錄路徑。 ~~~ $list = $this->ftp->list_files('/public_html/'); print_r($list); ~~~ >[info] ### mirror($locpath,?$rempath) 參數: * **$locpath**?(string) -- Local path * **$rempath**?(string) -- Remote path 返回: TRUE on success, FALSE on failure 返回類型: bool 遞歸的讀取文本的一個目錄和它下面的所有內容(包括子目錄),然后通過 FTP 在遠程服務器上創建一個鏡像。 無論原文件的路徑和目錄結構是什么樣的,都會在遠程服務器上一模一樣的重建。你需要指定一個原路徑和目的路徑: ~~~ $this->ftp->mirror('/path/to/myfolder/', '/public_html/myfolder/'); ~~~ >[info] ### mkdir($path[,?$permissions = NULL]) 參數: * **$path**?(string) -- Path to directory to create * **$permissions**?(int) -- Permissions (octal) 返回: TRUE on success, FALSE on failure 返回類型: bool 用于在服務器上創建一個目錄。需要指定目錄的路徑并以斜線結尾。 還可以通過第二個參數傳遞一個 八進制的值 設置權限。 ~~~ // Creates a folder named "bar" $this->ftp->mkdir('/public_html/foo/bar/', 0755); ~~~ >[info] ### chmod($path,?$perm) 參數: * **$path**?(string) -- Path to alter permissions for * **$perm**?(int) -- Permissions (octal) 返回: TRUE on success, FALSE on failure 返回類型: bool 用于設置文件權限。需要指定你想修改權限的文件或目錄的路徑: ~~~ // Chmod "bar" to 755 $this->ftp->chmod('/public_html/foo/bar/', 0755); ~~~ >[info] ### changedir($path[,?$suppress_debug = FALSE]) 參數: * **$path**?(string) -- Directory path * **$suppress_debug**?(bool) -- Whether to turn off debug messages for this command 返回: TRUE on success, FALSE on failure 返回類型: bool 用于修改當前工作目錄到指定路徑。 如果你希望使用這個方法作為?is_dir()?的一個替代,$suppress_debug?參數將很有用。 >[info] ### close() 返回: TRUE on success, FALSE on failure 返回類型: bool 斷開和服務器的連接。當你上傳完畢時,建議使用這個函數。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看