I'm trying to upload file using Kunnu Dropbox API. It works really well in localhost. But, when I try to upload from live server, it always upload empty file. What am i missing ?
Here is the code to upload :
$pathToLocalFile = base_url() . "\\public\\dropbox_file\\" . $data['upload_data']['file_name'];$dropBox = $this->load->library("DropBox_lib");$drop_obj = new DropBox_lib();$drop_obj->set_mode_file(1);$drop_obj->set_drop_file($pathToLocalFile); $drop_n = $drop_obj->drop_object; $file = $drop_n->simpleUpload($drop_obj->drop_file, $path_f . "/" . $data['upload_data']['file_name'], ['autorename' => true]);
Here is the Library of Dropbox_lib.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); use Kunnu\Dropbox\Dropbox; use Kunnu\Dropbox\DropboxApp; use Kunnu\Dropbox\DropboxFile; class DropBox_lib{ public $drop_object; public $drop_file; public $drop_mode; public function __construct() { require_once APPPATH.'third_party/DropBox/vendor/autoload.php'; //Configure Dropbox Application $app = new DropboxApp("xxxxxxxxxxxxxxxxx", "yyyyyyyyyyyyyyyyy", "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"); //Configure Dropbox service $this->drop_object = new Dropbox($app); } public function set_mode_file($mode){ if($mode == 1){ $mode = DropboxFile::MODE_READ; $this->drop_mode = $mode; }else{ $mode = DropboxFile::MODE_READ; $this->drop_mode = $mode; } } public function set_drop_file($pathlocal){ $dropboxFile = new DropboxFile($pathlocal, $this->drop_mode); $this->drop_file = $dropboxFile; } } ?>
The same codes work really well on localhost.
I think the problem is http request with SSL. Because my localhost is using http, while the live server using https