Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

afoysal's avatar

Upload file through API

I am updating data using API request like below.

$response = Http::withToken(Session::get('SesTok'))->post('https://sometext/profile-update', [
                "first_name" => $request->first_name,
                "last_name" => $request->last_name,
                "email" => $request->profile_email,       
            ]);

Now I need to upload File using API Request. I can fetch file details using $request->file('logo').

How can I Upload file through API ?

0 likes
4 replies
afoysal's avatar

Thanks @martinbean . Should I use like this ?

$response = Http::attach(
    'attachment', file_get_contents($request->file('logo')), 'photo.jpg'
)->post('http://example.com/attachments');

Please or to participate in this conversation.