色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

PHP實現ftp上傳文件示例

FTP上傳是php實現的一個常見且非常重要的應用技巧,今天就來與大家分享一下php實現FTP上傳文件的簡單示例。希望對大家的php學習能帶來一定的幫助。

主要代碼如下:

function make_directory($ftp_stream, $dir){  // if directory already exists or can be immediately created return true  if ($this->ftp_is_dir($ftp_stream, $dir) || @ftp_mkdir($ftp_stream, $dir)) return true;  // otherwise recursively try to make the directory  if (!$this->make_directory($ftp_stream, dirname($dir))) return false;  // final step to create the directory  return ftp_mkdir($ftp_stream, $dir);} function ftp_is_dir($ftp_stream, $dir){  // get current directory  $original_directory = ftp_pwd($ftp_stream);  // test if you can change directory to $dir  // suppress errors in case $dir is not a file or not a directory  if ( @ftp_chdir( $ftp_stream, $dir ) ) {    // If it is a directory, then change the directory back to the original directory    ftp_chdir( $ftp_stream, $original_directory );    return true;  } else {    return false;  }}$conn = ftp_connect("ftp地址") or die("Could not connect");ftp_login($conn,"ftpname","password");//利用ftp創建目錄make_directory($conn,$path);//利用ftp選擇進入目錄ftp_chdir($conn,$path);//開始上傳if(ftp_put($conn,$info[0]['savename'],getcwd().$upload->savePath.$info[0]['savename'],FTP_BINARY)){ unlink(getcwd().$upload->savePath.$info[0]['savename']);}ftp_close($conn);//注意上傳端的ftp權限設置

感興趣的朋友可以測試運行或改寫本文所述代碼,加深理解的同時可以讓代碼功能更加完善。

php技術PHP實現ftp上傳文件示例,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 西乌珠穆沁旗| 巧家县| 巴青县| 赤城县| 鹿邑县| 普兰店市| 湛江市| 阿巴嘎旗| 中超| 天峻县| 汝城县| 博乐市| 永顺县| 桦川县| 平果县| 石景山区| 繁昌县| 库尔勒市| 巴彦淖尔市| 烟台市| 阳新县| 荆门市| 嵊泗县| 同心县| 利川市| 浙江省| 镇雄县| 抚远县| 伊宁县| 莱阳市| 佛教| 通河县| 福海县| 新密市| 长沙市| 周至县| 高陵县| 甘孜县| 株洲县| 蚌埠市| 新巴尔虎左旗|