1.3.8 • Published 3 years ago

vue-easy-multi-file-upload v1.3.8

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

vue-easy-multi-file-uploader

File uploading made easy for vueJs. Custom validators, custom styling, file preview support for image & videos...

Please use the latest version.

Snapshot!

How to use

1. Install package via npm

npm i vue-easy-multi-file-upload --save

2. Import & use

<template>
  <div id="app">
    <VueEasyMultiFileUpload :config="config" v-model="values" />
    {{values}}
  </div>
</template>

<script>
import VueEasyMultiFileUpload from "vue-easy-multi-file-upload";

export default {
  components: { VueEasyMultiFileUpload },
  data() {
    return {
      config: {
        id: "multi-file-uploader",
        label: "Upload your files",
        maxFiles: 6,
        uploadUrl: "...",
        deleteUrl: "...",
        uploadHttpMethod: "POST",
        deleteHttpMethod: "DELETE",
        uploadFieldName: "file",
        deleteFieldName: "filePath",
        Authorization: "Bearer ...",
        style: {
          width: "90px",
          height: "75px",
        },
        allowExt: ["jpg", "png", "gif", "mp4", "txt", "webm", "pdf"],
        maxSize: 5,
        delimiter: "|",
        customValidator: (file) => {
          // ... custom validation logic ...
          return {
            status: true, // or false
            message: "It passes validation" // or null
          }
          // Tip: function can be async, can also return promise
        }
      },
      values: null
    };
  },
};
</script>

Props

There is only one prop i.e. config. Fields marked with asterisk(*) are required.

NameDescriptionDefault Value
**uploadUrl**URL to upload file. Specified request is sent as FormData.
*uploadHttpMethod**HTTP method for uploadUrl. Generally it's either POST or PUT.POST
*uploadFieldName**Name of key for FormData that holds file.file
deleteUrlURL to delete file. Specified request is sent to this url with application/json ContentType & uploaded file's path.
deleteHttpMethodHTTP method for deleteUrl. Generally its DELETE, can also be POST or PUT.DELETE
deleteFieldNamefieldName containing file path to delete.filePath
AuthorizationAuthorization header. eg: Beaker token
*allowExt**File extensions to allow. Used for validating file before upload.["jpg", "png", "gif", "mp4", "txt", "pdf"]
maxSizeMax size of file in Mb.
maxFilesMaximum number of files to upload
labelText to show at initial state. Also supports HTML.Upload a file
uploadingMessageText to show at uploading state. Also supports HTML.Loading...
styleCustom style for file upload section. Accepts style in plain string or object
delimiterIf delimiter is specified, a single string containing file paths seperated by delimeter is returned. eg: pipes, comma
idId of parent elementmulti-file-uploader
customValidatorCustom validation for uploaded file before sending it to server. View example above.
compressCompress images. Uses compressorjsfalse
compressorOptionsCompressorjs options. View compressorjs for more detailsnull

Events

NameDescription
@inputFired when new file is uploaded or existing file is deleted
1.3.8

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.10

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago