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

laracasts_asker's avatar

retrieving Data from request

hi, my linux server creates a file data.csv and now performes curl -d @data.csv http://laravelserver.com/ to post the file to my laravel server. The request gets routed succesfully to my controller with this route: Route::post('/', 'Controller@endpoint');

Can I now store data.csv so I can access it with $handle=fopen("/filepath/data.csv", "r");? Because than I can easily use while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) { to loop through the data line by line and save in a table. My challenge is to save data.csv on my laravel server and get the path. $file = $request->file('data.csv'); does not work: Filename cannot be empty. So curl does not transmits file name?

0 likes
3 replies
Snapey's avatar

some other client or server is POSTING to your server?

You are not explaining the setup very well.

laracasts_asker's avatar

Hi Snapey, thanks for your reply. I now updated the post with the requested info. Yes, there is another client that creates data.csv and the performes the curl.

Snapey's avatar

in endpoint method you need to see what is coming in. since this might be tricky from the curl side I would install beyondcode dump server so that you can dump the request to your console

Please or to participate in this conversation.