How to upload file from url via ftp using php?
How to upload image from url to ftp using php?

want to upload image from url to ftp

eg: http://test.com/imagefile.jpg or http://test.com/testvideo.flv

I want that file to upload via FTP or curl php,

I have sample code here but it doesn't work.

It say's no file found.



    $ftp_server ="ftp.yoursite.com"
    $ftp_user ="yoursite user"
    $ftp_password = "yoursite pass"
    $file_to_upload = "http://test.com/imagefile.png";
    $remote_location = "/test";
    
    // set up connection or exit with message
    $flink = ftp_connect($ftp_server) or exit("Can't connect to ftp server: $ftp_server");
    
    // login or at least try  
    if(ftp_login($flink, $ftp_user, $ftp_password)) {
    
    
     // if login successful use ftp_put to upload the file
     // if you upload binary files use mode FTP_BINARY
     if(ftp_put($flink, $remote_location, $file_to_upload, FTP_ASCII)) {
    
      echo "Success! File is uploaded!";
     } else {
      echo "Can't upload file";
    
     }
    } else {
     echo "Can't login with this user & password";
    
    }
    
    // close the connection
    ftp_close($flink);


Any one can help this problem? Or anyone can suggest better than this ?
Thank you! help very much appreciated.
How to upload file from url via ftp using php?
===

How to upload image from url to ftp using php?

want to upload image from url to ftp

eg: http://test.com/imagefile.jpg or http://test.com/testvideo.flv

I want that file to upload via FTP or curl php,

I have sample code here but it doesn't work.

It say's no file found.



    $ftp_server ="ftp.yoursite.com"
    $ftp_user ="yoursite user"
    $ftp_password = "yoursite pass"
    $file_to_upload = "http://test.com/imagefile.png";
    $remote_location = "/test";
    
    // set up connection or exit with message
    $flink = ftp_connect($ftp_server) or exit("Can't connect to ftp server: $ftp_server");
    
    // login or at least try  
    if(ftp_login($flink, $ftp_user, $ftp_password)) {
    
    
     // if login successful use ftp_put to upload the file
     // if you upload binary files use mode FTP_BINARY
     if(ftp_put($flink, $remote_location, $file_to_upload, FTP_ASCII)) {
    
      echo "Success! File is uploaded!";
     } else {
      echo "Can't upload file";
    
     }
    } else {
     echo "Can't login with this user & password";
    
    }
    
    // close the connection
    ftp_close($flink);


Any one can help this problem? Or anyone can suggest better than this ?
Thank you! help very much appreciated.