Uploader - url is required?
-
https://quasar.dev/vue-components/uploader#QUploader-API
tells me that url is not required
but this code<q-uploader :label="label" :multiple="multiple" class="full-width" auto-expand :auto-upload="autoUpload" :factory="uploadFactory" accept=".jpg, .png, .gif, image/*" ref="Uploader"> </q-uploader>
tells me
q-uploader: invalid or no URL specified
-
Did you pass a url in your factory?
-
uploadFactory(file) { let vm = this, data = new FormData(); return new Promise((resolve, reject) => { this.$axios.post('/upload', data, { headers: { 'Content-Type': 'multipart/form-data' } }) .then(response => { resolve(file); }) .catch(error => reject(error)) }); }
-
Any suggestions?
-
@matroskin Im getting the same error. Did you solved the problem?
-
Nope… Maybe I should send issue?
-
Interesting… In my code above, I changed
resolve(file)
toresolve(null)
It works, axios sending and no errors in console -
When I call “resolve(null)”, I have no errors in console, but the q-uploader-component shows me an error (red exclamation mark).
I don’t have an upload server either, the whole file processing takes place in the client. -
Hi,
Is there any update for this issue? I have the same problem.
Thanks
BR -
Hi,
I’m getting the same error, any suggestion ?
Thanks,
Jack -
@SyFab said in Uploader - url is required?:
When I call “resolve(null)”, I have no errors in console, but the q-uploader-component shows me an error (red exclamation mark).
I don’t have an upload server either, the whole file processing takes place in the client.I also would like to use q-uploader as a file selection and manipulate them with javascript. There’s no real upload to a server. Is there any ticket to change this already?
-
I solved it here: I didn’t set any url prop to q-uploader nor used a factory function. I just hid the upload button and got the @added event:
<template> <q-page class="flex flex-center"> <q-uploader style="width: 100%;" label="Restricted to images" multiple accept=".jpg, image/*" :hide-upload-btn="true" @added="onAdded" /> </q-page> </template> <script> export default { methods: { onAdded: function(files) { console.log(files) } } } </script>
-
Yeah, that’s the way. I do it in my project.