Form Upload

model-form can build file and image upload field with following codes

$form->file('file_column');
$form->image('image_column');

Change store path and name

// change upload path
$form->image('picture')->move('public/upload/image1/');

// use a unique name (md5(uniqid()).extension)
$form->image('picture')->uniqueName();

// specify filename
$form->image('picture')->name(function ($file) {
    return 'test.'.$file->guessExtension();
});

model-form both support for local and cloud storage upload

Upload to local

first add storage configuration, add a disk in config/filesystems.php:

set upload path to public/upload(public_path('upload')).

And then in config/admin.php select the disk set up above:

Set disk to the admin that you added above,directory.image and directory.file is the upload path for $form->image($column) and $form->file($column).

host is url prefix for your uploaded files.

Upload to cloud

If you need to upload to the cloud storage, need to install a driver which supports flysystem adapter, take qiniu cloud storage as example.

first install zgldh/qiniu-laravel-storage.

Also configure the disk, in the config/filesystems.php add an item:

Then modify the upload configuration of Ezadev-admin and open config/admin.php to find:

Select the above configuration qiniu for disk

Last updated