how to upload file from codeigniter app to dropbox

…衆ロ難τιáo~ 提交于 2019-12-13 05:05:06

问题


I have a controller to upload image to my web server. I want to upload that image to dropbox as well during the process. how would I do it?

This is my simple upload.php controller:

function index() {
    // get the binary data
    $file = file_get_contents("php://input");

    // prepare new name for upload image
    $name =rand().time().'jpg';

    $path = site_url('photo');

    // save to server directory
    file_put_contents($path.$name, $file);

    // save the name and id of the post to post photo table
    $input =  array(    'name' => $name,
                        'post_id'=> $id
                    );

    $this->db->insert('post_photo', $input);

}

回答1:


This blogpost has complete tutorial
how to use Dropbox api with codigniter using THIS CodeIgniter-Dropbox-API-Library

http://jimdoescode.blogspot.com/2011/07/codeigniter-dropbox-api.html




回答2:


try this its working good, for drop box create one new folder and just copy past the URL instead of" /upload " replace by /drop box URL

    $route=$_FILES['file_name']['name'];
    //var_dump($route);
    $target=realpath(APPPATH.'../uploads');
    $target=$target.'/'.$route;
    $tar=$route;
    $path=base_url().'uploads/'.$route;

    if(move_uploaded_file($_FILES['file_name']['tmp_name'],$target))
        echo "uploaded";
    else
        echo "not";


来源:https://stackoverflow.com/questions/29385257/how-to-upload-file-from-codeigniter-app-to-dropbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!