Resetting uploader button

I’m using the file uploader button component to save an image to files storage. Works great… and I’m using ‘background-image’ style property for the button to show users what the image in storage is.

I’m having a problem with updating that background after user successfully uploads an image… tried adding a delay, all sorts of things, to no avail. Here is the part of the code that’s relevant:

Why does this not show the “new” uploader button with the recently saved file as background?

Could you describe what the intended behavior is? I see you’re updating the background and then do a reset. What is the end goal?

End goal is the user sees the avatar they created, but they might “change their mind” and upload a different pic right then and there. Maybe that’s an edge case, perhaps it would be enough to show them the result and not reset the uploader button, but instead mount an image that gets the url from the database… just curious why the style change doesn’t happen when programmed into the “upload successful” logic :slight_smile:

Hi @Alex_Klein

Try using the upload button Styles Logic handler.

First - In the upload success event handler set imageURL to Uploaded Files.

image

Second - Add the following blocks to the upload button Styles Logic handler. The Styles Logic handler will refresh the button style when the status of the button changes… like when upload success has completed.

Regards
Glenn

Hi Glenn, that works a little better (works once but not if the user uploads images more than once). Actually I figured out that my problem was “browser cache”!

I had configured the uploader to generate a file name (unique to each user but always the same) and to overwrite existing file with that name. Just to be organized and to not accumulate garbage files… but the browser didn’t know the image had changed (because it always has the same URL/file name). If I change file name on each upload, things work fine.

But thanks so much for contributing a solution