Code Monkey home page Code Monkey logo

laravel-file-uploader's Introduction

Laravel File Uploader

This plugin register vue component to upload files using laravel-media-library.

Uploader

Requirements

You should install ahmed-aliraqi/laravel-media-uploader composer package to work successfully.

Installation

npm i laravel-file-uploader --save-dev

Basic Usage

<div id="app">
    <file-uploader
            :unlimited="true"
            collection="avatars"
            name="media"
            :tokens="{{ json_encode(old('media', [])) }}"
            label="Upload Avatar"
            notes="Supported types: jpeg, png,jpg,gif"
            accept="image/jpeg,image/png,image/jpg,image/gif"
    ></file-uploader>
</div>

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/laravel-file-uploader"></script>
<script>
  new Vue({
    el: '#app'
  })
</script>

Configure With Laravel Ui

// app.js

import FileUploader from 'laravel-file-uploader';

Vue.use(FileUploader);

Usage

<file-uploader :media="{{ $user->getMediaResource('avatars') }}"
               :unlimited="true"
               collection="avatars"
               name="media"
               :tokens="{{ json_encode(old('media', [])) }}"
               label="Upload Avatar"
               notes="Supported types: jpeg, png,jpg,gif"
               accept="image/jpeg,image/png,image/jpg,image/gif"
></file-uploader>
Attributes
Attribute Rule Type Description
name optional - default: media string the name of tokens fields
media optional - default: [] array used to display an existing files
unlimited optional - default:false boolean upload unlimited files - if let it false will not be multiple select
max optional - default:12 int the maximum uploaded files - if 1 will not me multiple select
accept optional - default: * string the accepted mime types
form optional - default: false string the form id of the uploaded media
notes optional - default null string the help-block that will be displayed under the files
label optional - default null string the label of the uploader
collection optional - default default string the media library collection that the file will store in
tokens optional - default: [] array the recently uploaded files tokens, used to display recently uploaded files in validation case
name optional - default: null array the input name of the uploader
Events
  • beforeUpload
  • complete
<file-uploader 
	label="Upload File" 
	@beforeUpload="handleBeforeUpload()"
	@complete="handleComplete()"
></file-uploader>

Note: Do not forget to store the laravel csrf token in an HTML meta tag:

<meta name="csrf-token" content="{{ csrf_token() }}">

laravel-file-uploader's People

Contributors

ahmed-aliraqi avatar arungpisyadi avatar juliomotol avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.