Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //upload.vue
- <template>
- <div id="dropzone">
- <div class="title m-b-md">
- Drop it like it's hot!
- </div>
- <dropzone id="myVueDropzone" :url="action" :headers="{ 'X-CSRF-TOKEN': csrf,'X-XSRF-TOKEN': xsrf }" v-on:vdropzone-success="showSuccess">
- </dropzone>
- </div>
- </template>
- <script>
- import Dropzone from "vue2-dropzone"
- export default {
- components: {
- Dropzone
- },
- props: {
- csrf: {
- type: String
- },
- xsrf: {
- type: String
- }
- ,
- action: {
- type: String
- }
- },
- methods: {
- showSuccess(file) {
- console.log('File uploaded' + file)
- }
- }
- }
- </script>
- //in the view
- test.blade.php
- <div class="panel panel-default">
- <upload csrf="{{ csrf_token() }}" xsrf="{!! Cookie::get('spark_token') !!} " action="/api/uploadPhoto">
- </upload>
- <image-list url="/list"></image-list>
- </div>
- //in route/api.php
- Route::group([
- 'middleware' => 'auth:api'
- ], function () {
- //Photo Controller
- Route::post('/uploadPhoto', 'PhotoController@upload');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement