I am storing filenames + their extensions
under filename
column in the files
table. My problem is, that since only the name is present in the $request
object without it's corresponding extension, I can't validate the filename using unique validation rule without tinkering with the input data first. Example:
// . . .
$this->validate($request, [
// Suppose the name of uploaded file is 'file'.
// The below rule will NEVER fail, because in the
// database, similar file will be stored as 'file.txt',
// thus 'file' != 'file.txt'
'filename' => 'unique:files'
]);
// . . .
Is there a way to validate the filename ignoring it's suffix (extension) in the database?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire