国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

PHP實現ftp上傳文件示例

2024-05-04 23:25:15
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了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權限設置

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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 河源市| 昌吉市| 化隆| 土默特右旗| 泸水县| 曲沃县| 湘阴县| 湘潭市| 潜江市| 浦江县| 江阴市| 北辰区| 泸水县| 张北县| 道孚县| 乐清市| 岚皋县| 鲁山县| 永年县| 南陵县| 宝丰县| 隆尧县| 宜兴市| 绥江县| 宜春市| 宜川县| 德惠市| 弥勒县| 房产| 杭锦后旗| 隆子县| 阿克陶县| 宁武县| 大兴区| 寿阳县| 呼图壁县| 广州市| 辛集市| 乐安县| 区。| 邹平县|