0

According to the docs, it seems the following file extraction should work:

<?php use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; Route::get('/', function (Request $request) { if ($request->hasFile('source' )) { return ">> GOOD ! <<"; } if ($request->hasFile('input.json')) { return ">> GOOD ! <<"; } $x = count($_FILES); return "DD >> $x << DD"; }); 

This is similar (but not identical1) to this post:

$ curl.exe -X GET -F "[email protected]" http://127.0.0.1:8008/ DD >> 0 << DD 

EDIT: When I change the receiving code to Route::post(...) then I get:

$ curl.exe -X POST -F "[email protected]" http://127.0.0.1:8008/ <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Page Expired</title> < ... omitted ... > 

1 In my case $_FILES is also empty

5
  • $request->hasFile('source') here source should be the name of the input type="file" name="source"field of your form Commented Mar 21, 2024 at 15:58
  • @krisgjika I don't have an explicit form - so I thought that specifying source in the http request should fit Commented Mar 21, 2024 at 16:01
  • 1
    than what do you have? just noticed this is a get route. If you want to pass files and other post data, make a post request to a post route Commented Mar 21, 2024 at 16:24
  • I have a micro service with a single endpoint running php code. Regarding the GET/POST point - when I change request type I get a long html response that doesn't make sense. I'll edit my question to add the details Commented Mar 21, 2024 at 16:44
  • A GET request can't have a file. And a 419 CSRF error is well-covered ground Commented Mar 21, 2024 at 17:47

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.