dourang8305 2016-07-21 10:33
浏览 81
已采纳

我是否应该在laravel 5.2中使用批量分配进行文件上传?

Hope everyone is doing great.

I have been using a laravel 5.2 for a few days now and I am stuck with the concept of either we should use mass assignment fillable /guarded for inserted file by and end user as the file gets uploaded to server and its path is stored in database and from that database table, gets the id stored in media table.

So my question actually is should we place a mass-assignment check n uploaded file to be inserted or updated or not. Either way, explanation is needed please. if possible, please attached the demonstrated examples as well for the approach adopted.

bundle of thanks in advance for everyone.

  • 写回答

2条回答 默认 最新

  • dongpo3957 2017-02-22 08:26
    关注

    Mass assignment is all about placing check on the input we get from the form. if a user tries to add a field by editing the source code (going in the inspect element section) and providing a value for other fields than allowed (mass-assigned), those values are ignored by framework. Yet if we make any change in any value programetically in our controller or model file, the changes take effect as that is done by developers at backend (server side) and not by some user at public end.

    So yes. Its a good practice to use mass-assignment in order to make sure only allowed fields are getting values from the form and not the other ones we don't wish to have stored in our db.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题