亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

目錄 搜尋
Array Array Helper Benchmarking Benchmarking Class Caching Caching Driver Calendaring Calendaring Class CAPTCHA CAPTCHA Helper Config Config Class Cookie Cookie Helper Database Connecting to your Database Custom Function Calls Database Caching Class Database Configuration Database Forge Class Database Metadata Database Quick Start: Example Code Database Reference Database Utility Class DB Driver Reference Generating Query Results Queries Query Builder Class Query Helper Methods Transactions Date Date Helper Directory Directory Helper Download Download Helper Email Email Class Email Helper Encrypt Encrypt Class Encryption Encryption Library File File Helper File Uploading File Uploading Class Form Form Helper Form Validation Form Validation FTP FTP Class Functions compatibility_functions common_functions HTML HTML Helper HTML Table HTML Table Class Image Manipulation Image Manipulation Class Inflector Inflector Helper Input Input Class Javascript Javascript Class Language Language Class Language Helper Loader Loader Class Migrations Migrations Class Number Number Helper Output Output Class Pagination Pagination Class Path Path Helper Security Security Class Security Helper Session Session Library Shopping Cart Shopping Cart Class Smiley Smiley Helper String String Helper Template Parser Template Parser Class Text Text Helper Trackback Trackback Class Typography Typography Class Typography Helper Unit Testing Unit Testing Class URI URL User Agent XML XML-RPC and XML-RPC Server Zip Encoding Zip Encoding Class XML-RPC and XML-RPC Server Classes XML Helper User Agent Class URL Helper URI Class
文字

CodeIgniter的FTP類允許文件傳輸?shù)竭h程服務(wù)器。遠程文件也可以被移動,重命名和刪除。FTP類還包含一個“鏡像”功能,允許通過FTP遠程重建整個本地目錄。

注意

不支持SFTP和SSL FTP協(xié)議,只有標(biāo)準(zhǔn)FTP。

  • 使用FTP類

    • 初始化類

    • 用法示例

  • 類參考

使用FTP類

初始化類

像CodeIgniter中的大多數(shù)其他類一樣,F(xiàn)TP類在您的控制器中使用$ this-> load-> library函數(shù)進行初始化:

$this->load->library('ftp');

一旦加載,F(xiàn)TP對象將可用:$ this-> ftp

用法示例

在這個例子中,向FTP服務(wù)器打開一個連接,并且以ASCII模式讀取和上傳本地文件。文件權(quán)限設(shè)置為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();

在這個例子中,從服務(wù)器中檢索一個文件列表。

$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();

在這個例子中,本地目錄在服務(wù)器上被鏡像。

$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();

類參考

class CI_FTPconnect([$config = array()])

參數(shù):

$ config(array) - 連接值

返回:

成功為TRUE,失敗為FALSE

返回類型:

布爾

  • $ configarray) - 連接值

Returns:  TRUE on success, FALSE on failure
Return type:  bool
連接并登錄到FTP服務(wù)器。連接首選項是通過將數(shù)組傳遞給函數(shù)來設(shè)置的,或者可以將它們存儲在配置文件中。

以下是一個顯示如何手動設(shè)置首選項的示例:

$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);

在配置文件中設(shè)置FTP首選項

如果您愿意,您可以將您的FTP首選項存儲在配置文件中。只需創(chuàng)建一個名為ftp.php的新文件,在該文件中添加$ config數(shù)組。然后將文件保存在application / config / ftp.php文件中,它將自動使用。

可用的連接選項

選項名稱默認(rèn)值說明**主機名**不適用FTP主機名(通常類似于:ftp.example.com)**用戶名**不適用FTP用戶名**密碼**不適用FTP密碼**端口* * 21 FTP服務(wù)器端口號** debug ** FALSE TRUE / FALSE(boolean):是否啟用調(diào)試以顯示錯誤消息** passive ** TRUE TRUE / FALSE(布爾值):是否使用被動模式

upload($locpath, $rempath[, $mode = 'auto'[, $permissions = NULL]])

參數(shù):

$ locpath(string) - 本地文件路徑$ rempath(string) - 遠程文件路徑$ mode(string) -  FTP模式,默認(rèn)為'auto'(選項為'auto','binary','ascii')$ permissions (int) - 文件權(quán)限(八進制)

返回:

成功為TRUE,失敗為FALSE

返回類型:

布爾

  • $ locpath字符串) - 本地文件路徑

  • $ rempath字符串) - 遠程文件路徑

  • $ mode字符串) -  FTP模式,默認(rèn)為'auto'(選項為:'auto','binary','ascii')

  • $ permissionsint) - 文件權(quán)限(八進制)

返回:成功時為TRUE,失敗時為FALSE
Return type:  bool
將文件上傳到您的服務(wù)器。您必須提供本地路徑和遠程路徑,并且可以選擇設(shè)置模式和權(quán)限。例:

$this->ftp->upload('/local/path/to/myfile.html', '/public_html/myfile.html', 'ascii', 0775);

如果使用“自動”模式,它將以源文件的文件擴展名為基礎(chǔ)。

如果設(shè)置,權(quán)限必須作為八進制值傳遞。

download($rempath, $locpath[, $mode = 'auto'])

參數(shù):

$ rempath(string) - 遠程文件路徑$ locpath(string) - 本地文件路徑$ mode(string) -  FTP模式,默認(rèn)為'auto'(選項為'auto','binary','ascii')

返回:

成功為TRUE,失敗為FALSE

返回類型:

布爾

  • $ rempath字符串) - 遠程文件路徑

  • $ locpath字符串) - 本地文件路徑

  • $ mode字符串) -  FTP模式,默認(rèn)為'auto'(選項為:'auto','binary','ascii')

返回:成功時為TRUE,失敗時為FALSE
Return type:  bool
從服務(wù)器下載文件。您必須提供遠程路徑和本地路徑,您可以選擇設(shè)置模式。例:

$this->ftp->download('/public_html/myfile.html', '/local/path/to/myfile.html', 'ascii');

如果使用“自動”模式,它將以源文件的文件擴展名為基礎(chǔ)。

如果下載未成功執(zhí)行(包括PHP沒有寫入本地文件的權(quán)限),則返回FALSE。

rename($old_file, $new_file[, $move = FALSE])

參數(shù):

$ old_file(字符串) - 舊文件名$ new_file(字符串) - 新文件名$ move(bool) - 是否正在執(zhí)行移動

返回:

成功為TRUE,失敗為FALSE

返回類型:

布爾

  • $ old_file字符串) - 舊文件名

  • $ new_file字符串) - 新文件名

  • $ movebool) - 是否正在執(zhí)行移動

Returns:  TRUE on success, FALSE on failure
Return type:  bool
允許您重命名文件。提供源文件名/路徑和新文件名/路徑。

//將green.html重命名為blue.html $ this-> ftp-> rename('/ public_html / foo / green.html','/public_html/foo/blue.html');

move($old_file, $new_file)

參數(shù):

$ old_file(字符串) - 舊文件名$ new_file(字符串) - 新文件名

返回:

成功為TRUE,失敗為FALSE

返回類型:

布爾

  • $ old_file字符串) - 舊文件名

  • $ new_file字符串) - 新文件名

Returns:  TRUE on success, FALSE on failure
Return type:  bool
讓你移動一個文件。提供源和目標(biāo)路徑:

// Moves blog.html from "joe" to "fred" $this->ftp->move('/public_html/joe/blog.html', '/public_html/fred/blog.html');

注意

如果目標(biāo)文件名不同,則文件將被重命名。

delete_file($filepath)

參數(shù):

$ filepath(字符串) - 要刪除的文件的路徑

返回:

成功為TRUE,失敗為FALSE

返回類型:

布爾

  • $ filepath字符串) - 要刪除的文件的路徑

Returns:  TRUE on success, FALSE on failure
Return type:  bool
讓你刪除一個文件。使用文件名提供源路徑。

$this->ftp->delete_file('/public_html/joe/blog.html');

delete_dir($filepath)

參數(shù):

$ filepath(字符串) - 要刪除的目錄的路徑

返回:

成功為TRUE,失敗為FALSE

返回類型:

布爾

  • $ filepath字符串) - 要刪除的目錄的路徑

Returns:  TRUE on success, FALSE on failure
Return type:  bool
允許您刪除目錄及其包含的所有內(nèi)容。用尾部斜杠提供目錄的源路徑。

重要

用這種方法非常小心!它將遞歸地刪除提供的路徑中的所有內(nèi)容,包括子文件夾和所有文件。確保你的路徑是正確的。先嘗試使用list_files()以驗證您的路徑是否正確。

$this->ftp->delete_dir('/public_html/path/to/folder/');

list_files([$path = '.'])

參數(shù):

$ path(string) - 目錄路徑

返回:

文件的數(shù)組列表或失敗時的FALSE

返回類型:

排列

  • $ pathstring) - 目錄路徑

返回:文件的數(shù)組列表或失敗時的FALSE
Return type:  array
允許您檢索服務(wù)器上以文件形式返回的文件列表。您必須提供所需目錄的路徑。

$list = $this->ftp->list_files('/public_html/'); print_r($list);

mirror($locpath, $rempath)

參數(shù):

$ locpath(字符串) - 本地路徑$ rempath(字符串) - 遠程路徑

返回:

成功為TRUE,失敗為FALSE

返回類型:

布爾

  • $ locpath字符串) - 本地路徑

  • $ rempathstring) - 遠程路徑

Returns:  TRUE on success, FALSE on failure
Return type:  bool
遞歸讀取本地文件夾及其包含的所有內(nèi)容(包括子文件夾),并基于此文件通過FTP創(chuàng)建鏡像。無論在服務(wù)器上重新創(chuàng)建原始文件路徑的目錄結(jié)構(gòu)。您必須提供源路徑和目標(biāo)路徑:

$this->ftp->mirror('/path/to/myfolder/', '/public_html/myfolder/');

mkdir($path[, $permissions = NULL])

參數(shù):

$ path(string) - 創(chuàng)建$ permissions的目錄路徑(int) - 權(quán)限(八進制)

返回:

成功為TRUE,失敗為FALSE

返回類型:

布爾

  • $ pathstring) - 要創(chuàng)建的目錄的路徑

  • $ permissionsint) - 權(quán)限(八進制)

Returns:  TRUE on success, FALSE on failure
Return type:  bool
讓您在服務(wù)器上創(chuàng)建一個目錄。提供以您希望創(chuàng)建的文件夾名稱結(jié)尾的路徑,并以斜杠結(jié)尾。

權(quán)限可以通過在第二個參數(shù)中傳遞八進制值來設(shè)置。

// Creates a folder named "bar" $this->ftp->mkdir('/public_html/foo/bar/', 0755);

chmod($path, $perm)

參數(shù):

$ path(string) - 修改$ perm(int)權(quán)限的路徑 - 權(quán)限(八進制)

返回:

成功為TRUE,失敗為FALSE

返回類型:

布爾

  • $ pathstring) - 修改權(quán)限的路徑

  • $ permint) - 權(quán)限(八進制)

Returns:  TRUE on success, FALSE on failure
Return type:  bool
Permits you to set file permissions. Supply the path to the file or directory you wish to alter permissions on:

// Chmod "bar" to 755 $this->ftp->chmod('/public_html/foo/bar/', 0755);

changedir($path[, $suppress_debug = FALSE])

參數(shù):

$ path(string) - 目錄路徑$ suppress_debug(bool) - 是否關(guān)閉此命令的調(diào)試消息

返回:

成功為TRUE,失敗為FALSE

返回類型:

布爾

  • $ pathstring) - 目錄路徑

  • $ suppress_debugbool) - 是否關(guān)閉此命令的調(diào)試消息

Returns:  TRUE on success, FALSE on failure
Return type:  bool
將當(dāng)前工作目錄更改為指定的路徑。

$suppress_debug如果您想將此方法用作is_dir()FTP 的替代方法,該參數(shù)非常有用。

close()

返回:

成功為TRUE,失敗為FALSE

返回類型:

布爾

上一篇: 下一篇: