Advertisement
AMONRA75

PHP - FTP CHECK FIND DELETE FILE

Jul 1st, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1.  
  2. $url="ftp://@95.211.239.22/binaxsql/binaxsql.sql";
  3. if (file_exists($url)) {
  4.  
  5.  
  6.     $ftp_server="95.211.239.28";  
  7.     $ftp_user_name="";  
  8.     $ftp_user_pass="";  
  9.     $file = '/binaxsql/binaxsql.sql';  
  10.     // set up basic connection  
  11.     $conn_id = ftp_connect($ftp_server);  
  12.     // login with username and password  
  13.     $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);  
  14.     // try to delete $file  
  15.     if (ftp_delete($conn_id, $file))  
  16.     {  
  17.     echo $file."deleted successful\n";  
  18.     }  
  19.         else  
  20.     {  
  21.     echo "could not delete".$file;  
  22.     }  
  23.     // close the connection  
  24.     ftp_close($conn_id);  
  25.  
  26.  
  27.  
  28. }else {
  29.  
  30.     $handle = fopen('ftp://@95.211.239.28/binaxsql/binaxsql.sql', 'w');
  31.  
  32.     //$handle = fopen('backup/backup.sql', 'w+');
  33.     fwrite($handle, $return);
  34.     fclose($handle);
  35.     echo "success";
  36.  
  37.  
  38.  
  39.  
  40.  
  41. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement