0

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);

}
2
  • 1
    A good start would be to look at the Dropbox API or even plugins written specifically for codeigniter, like this one Commented Apr 1, 2015 at 7:40
  • Does dropbox support email to upload files like Imgur? that would be pretty easy to set up Commented Apr 1, 2015 at 13:59

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

-1

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";

1 Comment

Won't work because it's not on the same server, not to mention the fact that dropbox wouldn't accept it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.