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

directory search
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
characters

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

注意

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

  • 使用FTP類

    • 初始化類

    • 用法示例

  • 類參考

使用FTP類

初始化類

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

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

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

用法示例

在這個(gè)例子中,向FTP服務(wù)器打開(kāi)一個(gè)連接,并且以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();

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

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

在這個(gè)例子中,本地目錄在服務(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) - 連接值

返回:

成功為T(mén)RUE,失敗為FALSE

返回類型:

布爾

  • $ configarray) - 連接值

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

以下是一個(gè)顯示如何手動(dòng)設(shè)置首選項(xiàng)的示例:

$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首選項(xiàng)

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

可用的連接選項(xiàng)

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

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

參數(shù):

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

返回:

成功為T(mén)RUE,失敗為FALSE

返回類型:

布爾

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

  • $ rempath字符串) - 遠(yuǎn)程文件路徑

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

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

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

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

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

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

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

參數(shù):

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

返回:

成功為T(mén)RUE,失敗為FALSE

返回類型:

布爾

  • $ rempath字符串) - 遠(yuǎn)程文件路徑

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

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

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

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

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

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

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

參數(shù):

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

返回:

成功為T(mén)RUE,失敗為FALSE

返回類型:

布爾

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

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

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

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(字符串) - 新文件名

返回:

成功為T(mén)RUE,失敗為FALSE

返回類型:

布爾

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

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

Returns:  TRUE on success, FALSE on failure
Return type:  bool
讓你移動(dòng)一個(gè)文件。提供源和目標(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(字符串) - 要?jiǎng)h除的文件的路徑

返回:

成功為T(mén)RUE,失敗為FALSE

返回類型:

布爾

  • $ filepath字符串) - 要?jiǎng)h除的文件的路徑

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

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

delete_dir($filepath)

參數(shù):

$ filepath(字符串) - 要?jiǎng)h除的目錄的路徑

返回:

成功為T(mén)RUE,失敗為FALSE

返回類型:

布爾

  • $ filepath字符串) - 要?jiǎng)h除的目錄的路徑

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

重要

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

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

list_files([$path = '.'])

參數(shù):

$ path(string) - 目錄路徑

返回:

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

返回類型:

排列

  • $ pathstring) - 目錄路徑

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

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

mirror($locpath, $rempath)

參數(shù):

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

返回:

成功為T(mén)RUE,失敗為FALSE

返回類型:

布爾

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

  • $ rempathstring) - 遠(yuǎn)程路徑

Returns:  TRUE on success, FALSE on failure
Return type:  bool
遞歸讀取本地文件夾及其包含的所有內(nèi)容(包括子文件夾),并基于此文件通過(guò)FTP創(chuàng)建鏡像。無(wú)論在服務(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)限(八進(jìn)制)

返回:

成功為T(mén)RUE,失敗為FALSE

返回類型:

布爾

  • $ pathstring) - 要?jiǎng)?chuàng)建的目錄的路徑

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

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

權(quán)限可以通過(guò)在第二個(gè)參數(shù)中傳遞八進(jìn)制值來(lái)設(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)限(八進(jìn)制)

返回:

成功為T(mén)RUE,失敗為FALSE

返回類型:

布爾

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

  • $ permint) - 權(quán)限(八進(jì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)試消息

返回:

成功為T(mén)RUE,失敗為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()

返回:

成功為T(mén)RUE,失敗為FALSE

返回類型:

布爾

Previous article: Next article: