I’m trying to upload a file to the configurator with a button “load file to configurator” (see minimal example below) and the configurator.uploadFile() function. But I’m not sure about the options of the function, e.g. the “HTML file object” and the “file ID”.
I always get the error: TypeError: b is undefined
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<title>File upload test</title>
<link rel="stylesheet" type="text/css" href="https://libs.paramate.trinckle.com/paramateViewport-latest.css">
<script src="https://libs.paramate.trinckle.com/paramateConfigurator-latest.js"></script>
<script src="https://libs.paramate.trinckle.com/paramateControls-latest.js"></script>
<script src="https://libs.paramate.trinckle.com/paramateViewportWebGL-latest.js"></script>
</head>
<body>
<div id="viewPort" style="width: 500px; height: 500px;"></div>
<div id="controls"></div>
<script>
var configurator
var viewPort
var controls
window.onload = function(){
// Create configurator object
configurator = new Paramate.Configurator({
APIHub: 'https://api.paramate.trinckle.com',
configuratorId: '588c596b-1a49-4423-b834-8b9a43a8f69f',
APIKey: '4db800982c753b662b75d065ccb77830'
});
// Create viewport object
viewPort = new Paramate.ViewportWebGL({
configurator: configurator,
viewportElement: document.getElementById('viewPort')
});
// Create controls object
controls = new Paramate.Controls({
configurator: configurator,
containerElement: document.getElementById('controls')
});
// Register viewport and controls
configurator.viewPort = viewPort;
configurator.controls = controls;
// Start configurator
configurator.initialize();
}
function getFileAndUpload(){
// get HTML file object
var HTMLfile = document.getElementById("LOGOupload");
console.log(HTMLfile);
// define ID to upload the file to
var fileID = "main:LOGOupload";
// upload file in configurator with options: HTML file object, file ID, progress, success
configurator.uploadFile(HTMLfile,fileID,function(progress){console.log(progress);},function(success){console.log(success);});
}
</script>
<!-- upload a file on webpage to create HTML file object -->
upload a file <input type="file" id="LOGOupload">
<br><br>
<!-- upload file in configurator -> "TypeError: b is undefined" -->
<button type="button" name="button" onclick="getFileAndUpload()">load file to configurator</button>
</body>
</html>