如何将文件从codeigniter应用程序上传到dropbox
问题描述:
我有一个控制器可以将图片上传到我的网络服务器。我想在该过程中将该图片上传到Dropbox。我将如何做呢?
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?
这是我简单的upload.php控制器:
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);
}
答
有完整的教程
如何使用Dropbox api与编码器,使用 This CodeIgniter-Dropbox-API-Library
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