Check if it's a file?
You may determine if a file is present on the request using the hasFile method:
if ($request->hasFile('photo')) {
//
}
I have a form that can have dynamic questions of any type (text, checkbox, file, radio button, textarea). To store the answers to these questions there is this code:
if (isset($request['answer'][$ticket][$nameKey])) {
foreach ($request['answer'][$ticket][$nameKey] as $question_id => $answer) {
$answer = Answer::create([
'question_id' => $question_id,
'user_id' => $user->id,
'answer' => $answer,
]);
}
}
But like this if the dynamic question is of type file, is only storing in the answers table like:
id user_id question_id answer
1 5 1 pdftest.pdf
But the file is not being stored in any folder, is only stored the name in db. Do you know what is necessary to detect if its a question of type file? And if it is store the file in some folder so then is possible to access the file?
Check if it's a file?
You may determine if a file is present on the request using the hasFile method:
if ($request->hasFile('photo')) {
//
}
Please or to participate in this conversation.