Support the ongoing development of Laravel.io →
Requests Input

Hi,

I'm build an webapp API that receives an image file from users using post forms and need to send this image to another server/application where it'll be processed.

I'm trying do to this using cURL, but on L5 all I can get is an error when I try to load the new CurlFile class from php-curl

new CurlFile($file_path,'file/exgpd',$file_name);

The error I got is:

Class 'App\Http\Controllers\CurlFile' not found

I believe this happens because of namespaces but I don't have a clue on how to deal with it.

Can anyone helpme with this?

thanks!

Last updated 3 years ago.
0

Don't know why, but I just tried to call the php class using a ' \ ' before and it just worked…

So for anyone with the same problem, use:

new \CurlFile($file_path,'file/exgpd',$file_name);

it worked as expected.

0

the class CurlFile is from the Curl extension. They need to be called with a \CurlFile because you're calling it from the App\Http\Controllers namespace.

0

Thanks for the explanation @astroanu :)

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.