Try the php move_uploaded_file. Which laravel through symfony uses anyway.
Edit:
Of course validate first as needed.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I am using CURL and I am receiving images in requests now I want to send data along with images to an external server via API, I am sending all data but I how will send images in API
$file = $request->file('documents');
curl_setopt_array($curl, array(
CURLOPT_URL => '#',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('DocumentType' => 'passport','DocumentFront'=> new CURLFILE('')),
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer '.$token
),
));
If you use the Http client you can base 64 encode it and send it as part of the request https://laravel.com/docs/9.x/http-client#sending-a-raw-request-body
Please or to participate in this conversation.