Custom image upload button

Hi. I have added an image upload button and a new email export button as we want our customer to upload some photos and then we want a copy of them.

This works fine if I upload the photo within the shapediver UI and use the new photo submit button.

I have now added a “choose file” button to our custom UI and I can’t connect it to the shapediver button.

This is what i have tried, but it doesn’t work - any ideas what might be wrong?

defaultListeners = function () {
    $("#photo-upload").on("change", function (event) {
        var file = event.target.files[0];
        var reader = new FileReader();
        reader.onload = function(e) {
            var base64data = e.target.result;
            api.parameters.updateAsync({name: '03d28633-96aa-4870-abef-1a196b316012', value: base64data}).then(function() {
                console.log("File uploaded successfully");
            });
        };
        
        reader.readAsDataURL(file);
    });
}

Thanks,

Axel :slight_smile:


Here is a full file input parameter example using the API of the version 2 of the viewer: https://codepen.io/ShapeDiver/pen/zYOJQXO

Let me know if this example solves your issue.

Note that free support and maintenance for the version 2 of the viewer will be discontinued on June 1st, 2024. We encourage you to migrate your application to version 3. Here is a migration guide: Viewer 2 - Migration Guide

Hi Mathieu,

Thank you for your prompt response. This works like a dream, so much appreciated :slight_smile:

In terms of version 2 of the viewer - when will it be phased out - meaning when will our models stop working? Is that happening June 1st, 2024?

We are about to send an official notice about viewer 2. The viewer will never be phased out, your models will keep working as always. However, it will not receive any more updates in case bugs and requests are reported by users. Free support via the forum will also be discontinued.

1 Like