Upload Button that allows document && image fileTypes

Hello!
I need to create an upload button that allows users to upload documents or images, as they are llikely to upload .PDF, .JPG, .JPEG, or .PNG files.

I’d like to check what type was uploaded, then upload to matching DB field (as fields are also limited to one fileType). Is this possible? At the moment I can only set 1 fileType to be allowed on the button.

$w("#myUploadButton").fileType = "Document";

Thanks!

1 Like

As you have stated above, you can set the file type by using the fileType function from within the Upload Button API.
https://www.wix.com/corvid/reference/$w.UploadButton.html#fileType

Therefore, simply set up a dropdown or radio button etc where the user selects the file type that they want to upload and then use that selection to set the file type for your upload button.

Otherwise, you will have to have multiple upload buttons for either image, document or video.

I have this same issue. It would be awesome if wix could implement support for ‘Document_or_Image’ (which seems easier to implement) or implement a way to allows us to select the extensions.

This function can be generated by code the hint is already given below, provided by “GOS”.

Please always open your own posts instead of bumping-up old ones.
Describe your issue as most as possible in detail.
You can link this post.

It’s possible to get the extension of file and change the #fileType after the file selection?