Input type file

I have img_name column in users table with varchar datatype to store IMGs names while moving IMGs to a folder. And in the form I have attachment input with file type.

Inside ‘controller add action’ I assign a unique name to the uploaded file to prevent any file replacement in the folder, but can’t assigning that same unique name to img_name as the DB responses with ‘Field img_name doesn’t have a default value’.
I tried to to assign the value from both beforeSave & beforeMarshal methods but nothing.

How are you assigning it into the data to be saved? Sounds like it’s not taking. Is img_name in the _accessible list for your entity? Did you clear your model cache after adding the field to the table?

Something like $user->img_name = ‘IMG_’ . time() . ‘.’ . $attachmentExtension;
And Yeah img_name is in the accessible list inside the entity, but I have no idea how to clear the model’s cache.

Failing to clear the cache is probably the #1 cause of issues that people post here, very easily remedied. Cache Tool - 4.x has a bit about command line tools to do it. Caching - 4.x discusses caching in general. Recommend that you get familiar with how it works.

Yeah, it is working after clearing the cache, thanks.