In the "Try Now" and when I tried implementing, I could not get the file type to be anything other than 'file' - and file.length seems undefined so the file size is always 0. Any ideas?
Hi Andy,
I have checked the respective Forge component's client action i.e. GetFileCotentType and observed a small JS mistake which is causing this problem.
Change 1:
Change 2:
Working JavaScript Snippet:
if (window.FileReader && window.Blob) { var uploadControl = document.querySelector('#' + $parameters.UploadId + ' > input[type="file"]'); var files = uploadControl.files; // this was missing var contentTypes = []; for(var i = 0; i < files.length; i++) { contentTypes[i] = files[i].type; } $parameters.ContentTypes = JSON.stringify(contentTypes); }
Hope this helps you!
Kind regards,
Benjith Sam
Works like a dream, thanks!