如何将文件从 codeigniter 应用程序上传到保管箱
how to upload file from codeigniter app to 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);
}
这篇博文有完整的教程
如何使用 Dropbox api 和 codeigniter 使用 THIS CodeIgniter-Dropbox-API-Library
http://jimdoescode.blogspot.com/2011/07/codeigniter-dropbox-api.html
试试这个效果很好,对于投递箱创建一个新文件夹并复制过去 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";
我有一个控制器可以将图像上传到我的网络服务器。在此过程中,我也想将该图像上传到保管箱。我该怎么做?
这是我的简单 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);
}
这篇博文有完整的教程
如何使用 Dropbox api 和 codeigniter 使用 THIS CodeIgniter-Dropbox-API-Library
http://jimdoescode.blogspot.com/2011/07/codeigniter-dropbox-api.html
试试这个效果很好,对于投递箱创建一个新文件夹并复制过去 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";