I am simply trying to display the name of the file I just uploaded via the file dropzone. I am using an event handler to change the value of a text component on the page. However, I'm getting a "type" error despite the fact that the tooltip identifies the field as a String and displays the correct value for the file I uploaded. When I run the application, the file uploads successfully but the event handler does not execute as desired, presumably because of this type validation error.
I tried to set up a simple test app mimicking the one Victoria created for that post and still encounter the error. Is there a bug? Am I doing something wrong? Any tips for debugging?
The linting error says your fileDropzone1.value[0].name is an array, which as you note, it is not. I just tried it on my end, and although the linter says there is an error, it still works. It was a little confusing because I was always showing the name of the first file in the upload component when adding additional files, but if I change it to show the last (or second or whatever) it works.
Does it not work for you ever at all, even if you fully clear the object and then start loading new files? Tagging @victoria who was on the last post you referenced as well in the event there was something to add from there, but I can't reproduce. Though also, why is the string being evaluated as an array by the linter?
Thanks for the quick reply @jg80. For me it never works. I know the event handler is firing because the value in the text component is cleared out when the upload completes.
But if we are only going to use the first file name (fileDropzone1.value[0].name ) we could do this without the event handler. Just set the value of the text directly:
We created a bug report for this issue. We should be able to reference the name of the first file regardless of how many files are added to the Dropzone. We'll update you here when is fixed.
Hello @Paulo
I got issue while using file dropzone
When I add change event and trigger an file validation, there I can't get file name, it shows that the filedropzone value is empty.
Hi @Paulo,
I am also experiencing this issue when an event hander is called on change. The fileDropZone.value is not updated within a javascript query and uses the old value. Changing the handler to parse seams to be a workaround for some reason. I'm using single file.