Laravel-从上传的文件中获取大小 [英] Laravel - get size from uploaded file

查看:2891
本文介绍了Laravel-从上传的文件中获取大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用此命令保存了文件

I have saved a file with this command

$newFile = [
            'event_id' => $event->id,
            'path' => $storePath
           ];

EventFile::create($newFile);

我可以通过以下链接获取文件的路径:

I can get the path to the file for a link like this:

Storage::disk('public')->url($file->path);

但是没有有关文件大小的数据.如何在刀片视图中获取文件大小?

But there is no data about the file size. How can i get the file size in blade view???

推荐答案

Laravel 5

$request->file('file')->getSize();

Laravel 4

$request->file('file')->getClientSize(); // getClientSize() is deprecated in Laravel 5

这篇关于Laravel-从上传的文件中获取大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆