How do I get raw form data in laravel

0 votes
I have a script that is trying to send data to my site using HTTP PUT. Normally, I woudl just retrieve it by reading from the input stream with file_get_contents('php://input'). However, when I try that with laravel, I don't get anything! Why not? How do I read the raw input data?
Oct 28, 2020 in Laravel by kartik
• 37,520 points
4,703 views

1 answer to this question.

0 votes

Hii @kartik,

Laravel intercepts all input. If you're using PHP prior to 5.6, the php://input stream can only be read once. This means that you need to get the data from the framework. You can do this by accessing the getContent method on the Request instance, like this:

$content = Request::getContent(); // Using Request facade
     /* or */ 
$content = $request->getContent();

Hope it works!!

answered Oct 28, 2020 by Niroj
• 82,840 points

Related Questions In Laravel

0 votes
1 answer

How do I catch exceptions / missing pages in Laravel 5?

Hello @kartik, In Laravel 5 you can catch ...READ MORE

answered Aug 11, 2020 in Laravel by Niroj
• 82,840 points
2,026 views
0 votes
1 answer

How do I get a “select count(*) group by” using laravel eloquent?

Hello @kartik, You could use this: $reserves = DB::table('reserves')->selectRaw('*, ...READ MORE

answered Oct 21, 2020 in Laravel by Niroj
• 82,840 points
35,614 views
0 votes
1 answer

How to get view data during unit testing in Laravel?

Hii, Try this: $response->getSession()->get("errors") And from there you can check ...READ MORE

answered Nov 2, 2020 in Laravel by Niroj
• 82,840 points
2,143 views
0 votes
1 answer

How do I include partials from a blade layout in laravel?

Hello @kartik, You need to give the full ...READ MORE

answered Nov 2, 2020 in Laravel by Niroj
• 82,840 points
4,180 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
23,012 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
2,995 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
2,918 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
44,694 views
0 votes
1 answer

How do I get HTTP Request body content in Laravel?

Hello @kartik, Inside controller inject Request object. So ...READ MORE

answered Aug 11, 2020 in Laravel by Niroj
• 82,840 points
17,036 views
0 votes
1 answer

How to get data from Laravel backend and display in Vue/Nuxt frontend

Hello, You have to use the package dotenv. Then ...READ MORE

answered Apr 8, 2020 in Laravel by Niroj
• 82,840 points
3,230 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP