Posted By

daisuke103 on 09/22/09


Tagged

php textmate upload FTP


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

BrianCoyDesign


PHP FTP アップロード


 / Published in: PHP
 

  1. //ファイルのアップロード
  2. $host = "xxxxxx";
  3. $username = "xxxxx";
  4. $password = "xxxxxxx";
  5. $uped = false;
  6.  
  7.  
  8. // FTP 接続を開く
  9. $ftps = ftp_connect($host);
  10. $result = ftp_login($ftps, $username, $password);
  11. if (!$result) {
  12. echo "接続に失敗しました。n";
  13. return;
  14. }else{
  15. echo "UPLOADED";
  16. $uped = true;
  17. }
  18.  
  19. // アップロード(相対パス)
  20. ftp_chdir($ftps, "/public_html/mydir");
  21. if($filename == "index"){
  22. ftp_put($ftps, $filename_r, "site/" . $filename_r, FTP_ASCII);
  23. }else{
  24. ftp_put($ftps, "x/main/" . $filename_r, "site/x/main/" . $filename_r, FTP_ASCII);
  25. }
  26.  
  27. // FTP 接続を閉じる
  28. ftp_quit($ftps);

Report this snippet  

You need to login to post a comment.