PHP code example of binbinly / narwhalformmedia

1. Go to this page and download the library: Download binbinly/narwhalformmedia library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

binbinly / narwhalformmedia example snippets


php artisan vendor:publish --provider=Narwhal\FormMedia\FormMediaServiceProvider

limit(int)      : 图片限制条数
remove(boolean) :  是否有删除按钮   

photo 、 photos 、 video  的 参数默认值不一样

photo  默认 limit = 1  remove = false

photos 默认 limit = 9  remove = true

video  默认 limit = 1  remove = true

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Demo extends Model
{
	
	public function getPicturesAttribute($pictures)
	{

	    return json_decode($pictures, true);

	}

}

安装教程 :https://github.com/jacobcyl/Aliyun-oss-storage

安装如果报错


Error Class 'Symfony\Component\Filesystem\Exception\FileNotFoundException' not found


则找到  出错文件 修改为:


    /**
     * @param $path
     *
     * @return string
     */
    public function getUrl( $path )
    {
        // if (!$this->has($path)) throw new FileNotFoundException($filePath.' not found');  //注释该行代码
        return ( $this->ssl ? 'https://' : 'http://' ) . ( $this->isCname ? ( $this->cdnDomain == '' ? $this->endPoint : $this->cdnDomain ) : $this->bucket . '.' . $this->endPoint ) . '/' . ltrim($path, '/');
    }


按照教程配置好了之后

把  admin.php 里面的  upload.disk  改为 oss  即可