export function button1_click(event, $w) {
if ($w( “#uploadButton1” ).value.length > 0 ) {
$w( “#text11” ).text = "Uploading " + $w( “#uploadButton1” ).value[ 0 ];
$w( “#uploadButton1” ).startUpload()
.then( (uploadedFile) => {
$w( “#text11” ).text = uploadedFile.url;
files($w( “#uploadButton1” ).value[ 0 ]);
})
. catch ( (uploadError) => {
$w( “#text11” ).text = “File upload error” ;
console.log( "File upload error: " + uploadError.errorCode);
console.log(uploadError.errorDescription);
});
}
else {
$w( “#text11” ).text = “Please choose a file to upload.” ;
}
}
function files( x){
let formdata = new FormData();
formdata.append( ‘file’ , x);
fetch( ‘https//:…’ ,{
method: ‘post’ ,
headers: {
‘Content-Type’ : ‘multipart/form-data’ ,
},
body: formdata
}).then(response => {
//something
}). catch (err => {
console.log(err)
}) ;
}
This code not work, and i get error “File not present” or no multipart boundary was found or this is not multipart request… dunno i have to do again ![]()