Skip to content
Advertisement

Can you send text and file for the same param?

I am trying to send a request to my PHP Laravel API that would store as “content” both files and text, however when i send the POST request, only the file path gets saved in the database and the request returns an array that is empty, is the problem from postman or my API?

enter image description here enter image description here

Here is the code for my post:

public function store(Request $request)
{
    $request->validate([
        'content' => 'required|max:255',
        'user_id' => 'required|exists:users,id',
        'item_id' => 'required|exists:items,id'
        ]);
    return Comment::create($request->all());
}

Advertisement

Answer

Try With change content to content[file] and content[text]
this is work for me

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement