Good a really good feeling something is not working with startUpload since I haven't touched the code and the upload feature is not working for me anymore. Not sure what is going on.
function Mobile_Optimize() {
if (wixWindow.formFactor === 'Mobile'){
Device = 'Mobile'
$w('#btnUploadBill').fileType = "Image"
$w('#btnUploadBill').buttonLabel = "Take Photo"
} else
if (wixWindow.formFactor === 'Desktop'){
Device = 'Desktop'
$w('#btnUploadBill').fileType = "Document"
$w('#btnUploadBill').buttonLabel = "Upload"
}
}
export function btnUploadBill_change(event) {
Start_uploadBill()
}
function Start_uploadBill() { console.log('Function started') if ($w("#btnUploadBill").value.length > 0) { $w("#txtUploading").expand() $w("#imgLoading").show() $w("#txtUploading").text = "Uploading..." $w("#btnUploadBill").startUpload() .then( (uploadedFile) => { console.log(uploadedFile.url) let image = uploadedFile.url; let url = image.split('/')[3]; let filename = 'ElectricBill'; if (Device === 'Desktop'){ UploadUrl = `https://docs.wixstatic.com/ugd/${url}?dn=${filename}` session.setItem('UploadUrl', UploadUrl) } else if (Device === 'Mobile'){ UploadUrl = `https://static.wixstatic.com/media/${url}?dn=${filename}` session.setItem('UploadUrl', UploadUrl) } $w("#imgLoading").hide() $w("#txtUploading").collapse() $w("#txtUploadSuccessful").expand() console.log(UploadUrl) }) } else { UploadUrl = "" $w("#txtUploading").expand() $w("#txtUploadSuccessful").collapse() $w("#txtUploading").text = "Please upload page" }}
Console.log(uploadedFile.url) is not showing up.
Because you're doing this in the oChange event handler, try adding
console.log($w("#btnUploadBill").value);
to the beginning of Start_uploadBill() to make sure that you're getting a filename. Maybe the change was triggered but the value isn't yet set.