Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Neeraj1005's avatar

preg_match(): Delimiter must not be alphanumeric or backslash (View: C:\laragon\www\crm\resources\views\rfq\lists-rfq.blade.php)

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;
        }
    }
0 likes
1 reply
newbie360's avatar

you need escape /

if (preg_match('/^image\//', $this->mime_type)) {
	return true;
}

return false;

Please or to participate in this conversation.