I want to upload file with dropbox Api using Laravel. I have used following Code for uploading from my drive to dropbox. But while Uploading I'm getting following Error:
InvalidArgumentException in Checker.php line 22: 'inStream' has bad type; expecting resource, got Illuminate\Http\UploadedFile
If anyone faced or solved the problem, help me to solve it please.
Here is my controller code:
public function dropboxFileUpload()
{
$Client = new Client(env('DROPBOX_TOKEN'), env('DROPBOX_SECRET'));
$dropboxFileName='';
$file = Input::file('image');
$size = Input::file('image')->getSize();
$name = Input::file('image')->getClientOriginalName();
$dropboxFileName = '/'.$name;
$Client->uploadFile($dropboxFileName,WriteMode::add(),$file, $size);
$links['share'] = $Client->createShareableLink($dropboxFileName);
$links['view'] = $Client->createTemporaryDirectLink($dropboxFileName);
print_r($links);
}
Here is the route part:
Route::post('dropboxFileUpload', 'ImportController@dropboxFileUpload');
And here is the view part:
<form style="border: 4px solid #a1a1a1;margin-top: 15px;padding: 10px;" action="{{ URL::to('dropboxFileUpload') }}" class="form-horizontal" method="post" enctype="multipart/form-data" >
<input type="file" name="image" />
{!! Form::token(); !!}
{!! csrf_field() ; !!}
<button class="btn btn-primary">Import File</button>
</form>