dongyidao1461 2016-08-21 05:09
浏览 42

Checker.php第22行中的Laravel Dropbox Fire Upload- InvalidArgumentException:

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>
  • 写回答

1条回答 默认 最新

  • dongxie9448 2016-08-21 08:13
    关注

    Can you please try

    $Client->uploadFile($dropboxFileName,WriteMode::add(),$file, $size, null, true);
    

    It's used for indication if the file is for testing purposes. This will skip validation.

    Second thing is to check if you create object of \Illuminate\Http\UploadedFile and not \Symfony\Component\HttpFoundation\File\UploadedFile

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作