Laravel-admin: 關於上傳檔案 (file upload)

Created on 1 Mar 2017  ·  7Comments  ·  Source: z-song/laravel-admin

請問要怎麼在上傳檔案時取得檔案的大小?

tmp

Most helpful comment

Try:

$form->file('file_path');
$form->hidden('file_size');

$form->saving(function ($form) {
    if ($form->file_path) {
        $form->file_size = $form->file_path->getClientSize();
    }
});

All 7 comments

你要在哪里获取到文件大小?

上傳的同時取得文件大小存入數據庫

Try:

$form->file('file_path');
$form->hidden('file_size');

$form->saving(function ($form) {
    if ($form->file_path) {
        $form->file_size = $form->file_path->getClientSize();
    }
});

成功接收到檔案大小數據,謝謝作者解惑

想再請問老師,如何取得檔案的原始名稱?

getClientOriginalName()

所有方法可以在这里看到 vendor/symfony/http-foundation/File/UploadedFile.php

看到了! 謝謝作者老師解惑

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cdhraesaemer picture cdhraesaemer  ·  3Comments

MarKco picture MarKco  ·  3Comments

amun1303 picture amun1303  ·  3Comments

qcol picture qcol  ·  3Comments

benny-sun picture benny-sun  ·  3Comments