├── .gitignore ├── README.md ├── babel.config.js ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html └── package.json └── src ├── App.vue ├── assets ├── logo.png └── preview.jpg ├── components └── Home.vue ├── main.js └── routes.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vue Multiple Image Upload (v1.0.10) 2 | 3 | # Welcome Back 4 | 5 | Hello Everyone,My name is **Zin Min Htet** and here is my [**Facebook account**](https://www.facebook.com/mm.zakerxa). 6 | 7 | Now, I will show you how to Upload Multiple Image using Vue-Component. 8 | 9 | There is an image Preview, Resize, Remove, Add More, Drag & Drop features are included. 10 | 11 | You can also limit the maximun number of file upload, the Image size , the Image type. 12 | 13 | I add new feature alert Box, Resize Image, Preview also can be resize in version 1.0.8; 14 | 15 | 16 | # Here is Live Demo 17 | 18 | preview 19 | 20 | **Watch Now [Live Demo](https://vue-multi-image-upload.vercel.app).** 21 | 22 | 23 | ## Installation 24 | 25 | ```NPM 26 | npm i @zakerxa/vue-multiple-image-upload 27 | ``` 28 | 29 | ## Setup 30 | 31 | **1 - Import the vue component locally in the script Tag** 32 | 33 | ```Vue 34 | 43 | ``` 44 | **OR** 45 | **Global registration in your main.js** 46 | 47 | ```Javascript 48 | import { VueMultiImageUpload } from '@zakerxa/vue-multiple-image-upload'; 49 | const app = createApp(App); 50 | app.component("vue-multi-image-upload", VueMultiImageUpload); 51 | 52 | ``` 53 | 54 | **2 - In your Vue Template** 55 | 56 | ```Vue 57 | 60 | ``` 61 | 62 | `⇃⇃⇃⇃⇂⇂⇂⇂` 63 | 64 | ```Vue 65 | 83 | ``` 84 | 85 | ## Props & Type 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 |
PropsData TypeDefaultOptionalDescription
maxNumber6YESUpload File Limit
PreviewObject{ h:100, w:100 }YESPreview Size h => height
ResizeObjectNo DefaultYES{ h:500, w:500 , keepRatio: true}
imageSizeNumber4e6YESImage File Size
alertTimeoutNumber3e3 (3s)YESAlert TimeOut
acceptArray[image/png, image/jpg, image/gif]YESImage's Format Validate
dataResetObjectfalseNoReset the child component data.
OptionsObject"Maximun","Ready","Selected"YESInput Box Message.
156 | 157 | ## Explanation of usage 158 | 159 | **1.Images methods can listen child input data from parent the component.** 160 | ``` 161 | @data-image="images" 162 | images(e){ 163 | e.map(res=>console.log(res)) 164 | } 165 | ``` 166 | 167 | **2.We can Resize the images by adding resize props** 168 | ``` 169 | :resize={ h:500, w:500 ,keepRatio:true} 170 | h => max-height of the image 171 | w => max-width of the image 172 | 173 | keepRatio true can resize your image without losing distortion 174 | keepRatio false can resize your image exactly width & height 175 | 176 | Default is False 177 | ``` 178 | 179 | 180 | **3.We can limit the number of image to upload maximun** 181 | ``` 182 | :max="limitNumber" 183 | ``` 184 | 185 | **4.We can also limit the images size & type.** 186 | ``` 187 | :image-size="imageSize" :accept="imageType" 188 | 189 | this.imageSize = 2e6; // 2MB 190 | ImageSize only allow 2MB else We will show alert msg to user. 191 | 192 | this.imageType = ['image/jpeg', 'image/png', 'image/gif']; 193 | imageType should be inside an array 194 | ``` 195 | 196 | **5.And, There is one options.Options can change the message inputBox.** 197 | ``` 198 | :options="options" 199 | this.options.max = "Max"; 200 | this.options.ready = "Ready"; 201 | this.options.select = "Choosed"; 202 | ``` 203 | 204 | **6.If you want to reset child component data,You can use :data-reset props to passing Object** 205 | ``` 206 | :data-reset="components" 207 | this.component.clear = true; 208 | ``` 209 | 210 | ## Final State 211 | 212 | **That's all what you need** 213 | 214 | ```Vue 215 | 229 | 230 | 261 | 262 | ``` 263 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ["@vue/cli-plugin-babel/preset"], 3 | }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@zakerxa/github-multiple-image-upload", 3 | "version": "1.0.10", 4 | "license": "MIT", 5 | "description": "This is a vue-component multiple image upload with preview.I hope this can help you a lot.", 6 | "keywords": [ 7 | "Vue Multiple Image Upload", 8 | "Vue Multi Image Upload", 9 | "Vue Multiple Image", 10 | "Vue Laravel Multiple Image Upload", 11 | "Multiple Image Upload", 12 | "MultipleImageUpload", 13 | "Laravel Vue Multiple Image" 14 | ], 15 | "author": "Zin Min Htet", 16 | "homepage": "https://github.com/Zakerxa/Vue-Multi-Image-Upload#readme", 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/Zakerxa/Vue-Multi-Image-Upload.git" 20 | }, 21 | "bugs": { 22 | "url": "https://github.com/Zakerxa/Vue-Multi-Image-Upload/issues", 23 | "email": "zakerxa@gmail.com" 24 | }, 25 | "private": true, 26 | "scripts": { 27 | "s": "vue-cli-service serve", 28 | "build": "vue-cli-service build", 29 | "test:unit": "vue-cli-service test:unit", 30 | "lint": "vue-cli-service lint" 31 | }, 32 | "dependencies": { 33 | "@zakerxa/vue-multiple-image-upload": "^1.0.10", 34 | "vue-router": "^4.1.5" 35 | }, 36 | "devDependencies": { 37 | "@vue/cli-plugin-babel": "~4.5.13", 38 | "@vue/cli-plugin-eslint": "~4.5.13", 39 | "@vue/cli-plugin-unit-jest": "~4.5.13", 40 | "@vue/cli-service": "~4.5.13", 41 | "@vue/compiler-sfc": "^3.0.0", 42 | "@vue/eslint-config-prettier": "^6.0.0", 43 | "@vue/test-utils": "^2.0.0-0", 44 | "babel-eslint": "^10.1.0", 45 | "eslint": "^6.7.2", 46 | "eslint-plugin-prettier": "^3.3.1", 47 | "eslint-plugin-vue": "^7.0.0", 48 | "prettier": "^2.2.1", 49 | "sass": "^1.26.5", 50 | "sass-loader": "^8.0.2", 51 | "typescript": "~3.9.3", 52 | "vue-jest": "^5.0.0-0" 53 | }, 54 | "eslintConfig": { 55 | "root": true, 56 | "env": { 57 | "node": true 58 | }, 59 | "extends": [ 60 | "plugin:vue/vue3-essential", 61 | "eslint:recommended" 62 | ], 63 | "parserOptions": { 64 | "parser": "babel-eslint" 65 | }, 66 | "rules": {}, 67 | "overrides": [ 68 | { 69 | "files": [ 70 | "**/__tests__/*.{j,t}s?(x)", 71 | "**/tests/unit/**/*.spec.{j,t}s?(x)" 72 | ], 73 | "env": { 74 | "jest": true 75 | } 76 | } 77 | ] 78 | }, 79 | "browserslist": [ 80 | "> 1%", 81 | "last 2 versions", 82 | "not dead" 83 | ], 84 | "jest": { 85 | "preset": "@vue/cli-plugin-unit-jest", 86 | "transform": { 87 | "^.+\\.vue$": "vue-jest" 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zakerxa/Vue-Multi-Image-Upload/35c12251fc420c2c48f19acd4f2e7b29606429dc/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | <%= htmlWebpackPlugin.options.title %> 11 | 12 | 13 | 14 | 15 | 16 | 26 | 27 | 28 | 32 |
33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /public/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-multi-image-upload", 3 | "version": "1.0.1", 4 | "license": "MIT", 5 | "description": "This is a vue-component multiple image upload with preview.I hope this can help you a lot.", 6 | "keywords": [ 7 | "Vue Multiple Image Upload", 8 | "Vue Multi Image Upload", 9 | "Vue Multiple Image", 10 | "Vue Laravel Multiple Image Upload", 11 | "Multiple Image Upload", 12 | "MultipleImageUpload", 13 | "Laravel Vue Multiple Image" 14 | ], 15 | "author": "Zin Min Htet", 16 | "homepage": "https://github.com/Zakerxa/Vue-Multi-Image-Upload#readme", 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/Zakerxa/Vue-Multi-Image-Upload.git" 20 | }, 21 | "bugs": { 22 | "url": "https://github.com/Zakerxa/Vue-Multi-Image-Upload/issues", 23 | "email": "zakerxa@gmail.com" 24 | }, 25 | "private": true, 26 | "scripts": { 27 | "s": "vue-cli-service serve", 28 | "build": "vue-cli-service build", 29 | "test:unit": "vue-cli-service test:unit", 30 | "lint": "vue-cli-service lint" 31 | }, 32 | "dependencies": { 33 | "@zakerxa/vue-multiple-image-upload": "^1.0.0" 34 | }, 35 | "devDependencies": { 36 | "@vue/cli-plugin-babel": "~4.5.13", 37 | "@vue/cli-plugin-eslint": "~4.5.13", 38 | "@vue/cli-plugin-unit-jest": "~4.5.13", 39 | "@vue/cli-service": "~4.5.13", 40 | "@vue/compiler-sfc": "^3.0.0", 41 | "@vue/eslint-config-prettier": "^6.0.0", 42 | "@vue/test-utils": "^2.0.0-0", 43 | "babel-eslint": "^10.1.0", 44 | "eslint": "^6.7.2", 45 | "eslint-plugin-prettier": "^3.3.1", 46 | "eslint-plugin-vue": "^7.0.0", 47 | "prettier": "^2.2.1", 48 | "sass": "^1.26.5", 49 | "sass-loader": "^8.0.2", 50 | "typescript": "~3.9.3", 51 | "vue-jest": "^5.0.0-0" 52 | }, 53 | "eslintConfig": { 54 | "root": true, 55 | "env": { 56 | "node": true 57 | }, 58 | "extends": [ 59 | "plugin:vue/vue3-essential", 60 | "eslint:recommended" 61 | ], 62 | "parserOptions": { 63 | "parser": "babel-eslint" 64 | }, 65 | "rules": {}, 66 | "overrides": [{ 67 | "files": [ 68 | "**/__tests__/*.{j,t}s?(x)", 69 | "**/tests/unit/**/*.spec.{j,t}s?(x)" 70 | ], 71 | "env": { 72 | "jest": true 73 | } 74 | }] 75 | }, 76 | "browserslist": [ 77 | "> 1%", 78 | "last 2 versions", 79 | "not dead" 80 | ], 81 | "jest": { 82 | "preset": "@vue/cli-plugin-unit-jest", 83 | "transform": { 84 | "^.+\\.vue$": "vue-jest" 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zakerxa/Vue-Multi-Image-Upload/35c12251fc420c2c48f19acd4f2e7b29606429dc/src/assets/logo.png -------------------------------------------------------------------------------- /src/assets/preview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zakerxa/Vue-Multi-Image-Upload/35c12251fc420c2c48f19acd4f2e7b29606429dc/src/assets/preview.jpg -------------------------------------------------------------------------------- /src/components/Home.vue: -------------------------------------------------------------------------------- 1 | 76 | 77 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import { createApp } from "vue"; 2 | import App from "./App.vue"; 3 | import { VueMultiImageUpload } from "@zakerxa/vue-multiple-image-upload"; 4 | import routes from "./routes"; 5 | 6 | 7 | const app = createApp(App); 8 | app.use(routes); 9 | app.component("VueMultiImageUpload", VueMultiImageUpload); 10 | app.mount("#app"); -------------------------------------------------------------------------------- /src/routes.js: -------------------------------------------------------------------------------- 1 | import { createRouter, createWebHistory } from 'vue-router'; 2 | 3 | const routes = [{ 4 | path: '/', 5 | name: 'home', 6 | component: require('./components/Home.vue').default 7 | }] 8 | 9 | 10 | 11 | 12 | const router = createRouter({ 13 | history: createWebHistory(process.env.BASH_URL), 14 | routes 15 | }); 16 | 17 | export default router; --------------------------------------------------------------------------------