dousuie2222 2019-08-09 08:52
浏览 118

使用guzzle将文件从流明服务器发送到另一个php服务器

I'm into developing an mobile app using Cordova and I'm using Laravel Lumen as my API server and my mobile app has this part where you browse picture, edit it with third party image editor plugin then it will output a base64, then I convert it to blob then use the FormData() to send it to my Lumen API server, I can confirm the file by $_FILES['avatar'] or even by using Laravel Storage Storage::putFile('avatars', ''); and upon var dump, it returns

enter image description here

after that I use, Guzzle to send the received file from the Lumen API server to another PHP server (Codeigniter)

$data = [];

foreach( $request->input() as $key => $val){
    $data[] = [
        'name' => $key,
        'contents' => $val
    ];
} // append the extra datas first

$data[] = [
    'name' => 'avatar',
    'contents' =>  ( isset( $_FILES['avatar'] ) ) ? $_FILES['avatar'] : false
]; // append the file

// send to another server
$res = $this->client->request('POST','https://myapiserver.com/api/update/profile',
    [ 
        'multipart' => $data
    ]
);

return response()->json(json_decode($res->getBody()->getContents()));

Unfortunately, below image is the returned error. Any help, ideas please?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端
    • ¥15 基于PLC的三轴机械手程序
    • ¥15 多址通信方式的抗噪声性能和系统容量对比
    • ¥15 msix packaging tool打包问题
    • ¥15 finalshell节点的搭建代码和那个端口代码教程
    • ¥15 Centos / PETSc / PETGEM