top of page
  • Writer's pictureArun Kumar

Upload Image and Show in Image Box

To upload and image using wix upload button and show the image inside an image box, we must use upload button onChange() event.


For example, we have an upload button to upload profile picture


Here is the code for the upload button onChange() event

//extract url from uploaded file and change image in the imagebox

export function uploadPicBtn_change(event) {
    
    if (event.target.value.length > 0) {
        $w("#uploadPicBtn").startUpload()
        .then((uploadedFile) => {
            $w('#contactImage').src = uploadedFile.url;
        })
        .catch((uploadError) => {
            console.log(`Error: ${uploadError.errorCode}`);
            console.log(uploadError.errorDescription);
        });
    }

}

Enjoy!! 😎😎😎

5 views0 comments

Recent Posts

See All
bottom of page