Avatar or Profile Picture

Hello professionals, I need your help please. I have a lot of coding and base initial knowledge. How can I motivate user to make a selection? That means that user can choose an avatar or upload a profile picture, so that it will be in my Database1? With my onClick event a selection works now but how can I trigger the upload - thanks Yulia

You need an upload button
then try this link:
https://support.wix.com/en/article/corvid-tutorial-using-the-upload-button-with-code

Here’s the code they used:

if($w("#uploadButton1").value.length > 0) {     
$w("#uploadButton1").startUpload()       
.then( (uploadedFile) => {        
 //write what you want to use the uploaded file for
   })      
 .catch( (uploadError) => {         
 console.log("File upload error: " + uploadError.errorCode); console.log(uploadError.errorDescription);       
 });   }  
 else {    
//write a function that runs if upload button is empty
 }

DJ bon26

Dear DJ bon26, thanks for your support - very good link.

It works enclosed my code, but what I want now ist, if the user does not want to upload a file, he/she should select an avatar above and upload it … can you please help me with the code? Pllleeeeassseee :slight_smile: Thank youu

export function button13_click(event) {
if ($w( “#uploadButton2” ).value.length > 0 ) {
$w( “#text119” ).text = "Uploading " + $w( “#uploadButton2” ).value[ 0 ].name;
$w( “#uploadButton2” ).startUpload()
.then( (uploadedFile) => {

/////here?

    $w( "#text119" ).text =  "Upload successful" ; 
    $w( "#image7" ).src = uploadedFile.url; 
  }) 
  . **catch** ( (uploadError) => { 
    $w( "#text119" ).text =  "File upload error" ; 
    console.log( "File upload error: "  + uploadError.errorCode); 
    console.log(uploadError.errorDescription); 
  }); 

}
else {
$w( “#text119” ).text = “Please choose a file to upload.” ;
}
}