replace_image only run first time

25 June 2019 14:11

First of all, sorry about my little english, i hope it's enough for you to understand me.

I'm developing a martress configurator where the user must be able to change the embroidery of the side of the martress from a local png file.
In order to do that, i replace the png file of the texture in the server using js+php, and refresh the texture using the replace_image function.
When I run the app, the first time i change the texture works fine, but it doesn't work anymore untill i refresh the complete web page.

Here is the code:

function eNviar(inputFile){//This function replaces the texture file in the server with the user's local one.
if (inputFile.files.length > 0) {
let formData = new FormData();
formData.append("archivo", inputFile.files[0]); //
fetch("http://localhost/upload_pic.php", {
method: 'POST',
body: formData,
.then(respuesta => respuesta.text())
.then(decodificado => {
} else {
alert("Select a file");
function change_bordado(){ //Here is where i try to refresh the image
var imagen = new Image();
m_textures.replace_image(objetoBordado150Front, "bordado_claro", imagen);

Any suggest?

Thanks in advance!
01 July 2019 14:30
Hi again!

I solved the problem!

I was overwritting the same of the texture, so the filename never changed. So 'replace_image()' didn't detect different file so it didn't detect the change, and did nothing.
To solve the problem I added an autoincremental number to the file name, so it's never the same file and the function 'replace_image()' works fine.
Please register or log in to leave a reply.