Level 24
you need escape /
if (preg_match('/^image\//', $this->mime_type)) {
return true;
}
return false;
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
In my project I have file upload system with file and image support... In front page I want to perform a query if user has upload an image then image show other wise not show document... So I make a function in model it throw some errro can anyone tell what i did wrong
protected $fillable = [
'imageable_id',
'imageable_type',
'file_name',
'mime_type',
'file_path',
];
public function fileType()
{
$value = preg_match('image/',$this->mime_type);
if ($value) {
return true;
}
}
Please or to participate in this conversation.