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 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口