简体   繁体   中英

how to upload image in key cdn using php?

i want to upload image in keycdn using php at a time of every image upload in my site.

Option available rsync or ftp but it is not useful for me.

so, can you please help me for this using php directly.

I think you should achieve your goal via this trick.

Directly not any method available but via ftp using PHP it is possible.

<?php

function uploadFTP($server, $username, $password, $local_file, $remote_file){
    // connect to server
    $connection = ftp_connect($server);

    // login
    if (@ftp_login($connection, $username, $password)){
        // successfully connected
    }else{
        return false;
    }

    ftp_put($connection, $remote_file, $local_file, FTP_BINARY);
    ftp_close($connection);
    return true;
}

uploadFTP("ftp.keycdn.com", "yourusername", "yourpassword", "test.jpg", "/cdn/test.jpg");
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM