My code is simple as follow. When I upload the image from upload button, it shows file upload error. When I checked the image size, it is ok to upload. Can someone solve for this ?
function uploadPic ( btn , textStatus , previewImg ) {
console . log ( btn )
$w ( ‘#dataset1’ ). onReady (()=>{
if ( $w ( btn ). value . length > 0 ) {
$w ( textStatus ). show ()
$w ( textStatus ). text = "(Uploading " + $w ( btn ). value [ 0 ]. name + “)” ;
$w ( btn ). uploadFiles ()
. then (( uploadedFiles ) => {
console . log ( uploadedFiles )
$w ( textStatus ). text = “(Successfully Uploaded)” ;
$w ( previewImg ). src = uploadedFiles [ 0 ]. fileUrl ;
setTimeout (() => $w ( textStatus ). hide (), 2500 )
})
. catch (( uploadError ) => {
$w ( textStatus ). text = “(File upload error)” ;
console . log ( "File upload error: " + uploadError . errorCode );
console . log ( uploadError . errorDescription );
}
);
} else {
$w ( textStatus ). text = “(Please choose a file to upload)” ;
}
})
}