我有一个控制器将图像上传到我的网络服务器。我想在此过程中将该图像上传到Dropbox。我该怎么做?
这是我的简单upload.php控制器:
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);
}
答案 0 :(得分:2)
此博文有完整的教程
如何使用THIS CodeIgniter-Dropbox-API-Library
http://jimdoescode.blogspot.com/2011/07/codeigniter-dropbox-api.html
答案 1 :(得分:-1)
试试这个工作的好处,对于drop box创建一个新文件夹,只需复制过去的URL而不是“/ upload”替换为/ 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";