warning: startUpload is deprecated

I’m getting this note in the console:
Wix code SDK warning: startUpload is deprecated. Please use uploadFiles instead.

Can’t find uploadFiles() in the API Reference, and my code is starting to malfunction, especially on mobile, and not for images - only documents or audio files.
The files are always under size limitations, and the function is the same for all file types and works perfectly on a desktop.

It seems that some days ago, there were some changes on the upload-function. Do you still have the same issues?

Hi @shimistudio & @russian-dima , similar issues here… upload buttons were working fine and some days ago I started to receive errors when uploading new files or trying to change files that are already uploaded… any ideas what’s going on?

@rusty
https://www.wix.com/velo/forum/coding-with-velo/form-image-is-not-saving-to-database

Same problem for me. I’m going to contact wix support urgently

Whats exactly the ERROR with the Uploader?
My Upload-Buttons just working fine.

@russian-dima when it tries to save to collection, I have this problem
It started 5 days ago more or less but I believed it was related to a user until I made a deep check :frowning:

@autore Ok, i think here i can’t really help you out —>tag Yisrael.

@russian-dima Thanks anyway for your trial. I believe it’s a bug since I did not change anything. I’ll call support in opening hours to have it fixed.

@autore Good luck !

@autore it should still work, even with this message. it’s working for me 90% of the cases…

@yisrael-wix Hi! 've just opened a ticket since all my users are not able to register anymore at my site :frowning:
Any proposal?
Thanks

I’m not aware of any issue regarding uploading files. Let’s see what Customer Care says.

Meanwhile, please share your code in a code block so that we can see what it is you are doing.

@yisrael-wix
This code was working 5 days ago… and now it’s not working in all website from all pages. :frowning:
The problem is not in the button because the file is correctly managed, but when the “send” button tries to save the file to collection. Something has changed.
I’ve tried file upload also to other collections with the same problem “warning: startUpload is deprecated”.

export async function uploadButton1_change ( event ) {
$w ( ‘#uploadButton1’ ). startUpload ()
. then ( ( uploadedFile ) => {
$w ( ‘#image1’ ). src = uploadedFile . url ;
$w ( ‘#ImageScheda’ ). src = uploadedFile . url ;
});
}

@autore What are you doing with the send button? Does it have code? Is it connected to a dataset? Please provide all of the relevant code and details.

@autore Please add the code of the send button or if you have it connected to a dataset you don’t actually need to upload the file first. the submit on the button connected to the write dataset will upload the file then save to the record.

@yisrael-wix / @digital-edge hi, just to support @David’s case, the very similar problem’s here.

Upload button’s code:

export function uploadButton1_change(event) {
$w("#text317").collapse();
let files = $w("#uploadButton1").value;
let fileSize = Number(files[0].size);
let mySizeLimit = 4194304;
if (fileSize > mySizeLimit) {
setTimeout(()=>{
$w("#uploadButton1").reset();
$w("#text317").expand();
$w("#image2").hide();
},100)
}

else {
setTimeout(()=>{
$w("#uploadButton1").buttonLabel = 'Loading...'; 
$w("#uploadButton1").startUpload() 
.then( (uploadedFile) => { 
$w("#image2").src = uploadedFile.url; 
$w("#image2").show();
$w("#uploadButton1").buttonLabel = 'Upload photo'; 
}) 
.catch( (uploadError) => { 
console.log(`Error: ${uploadError.errorCode}`);  console.log(uploadError.errorDescription); 
}); 
},100) 
}
}

The upload button is connected to the dataset via user interface:

Submit button has a very simple code only, nothing that should be causing the issue:

export function button2_click(event) {
$w("#columnStrip76").collapse();
$w("#image1").show();
$w("#columnStrip80").expand();
$w("#button2").hide();
}


To address Scott’s point “you don’t actually need to upload the file first”, I’m doing it to enable the preview of the image before the dataset’s submitted, as seen in uploadButton’s code…

This all worked fine till few days ago, now I’m getting an error: The ‘image_name.jpg’ file failed to upload. Please try again later. TypeError: Cannot read property ‘0’ of undefined.

This error is received when the submit button is clicked (i.e. the whole form is NOT submitted).
The code that’s triggered on upload button change does not log any errors.

Thanks for support guys!

@rusty I would personally disconnect the upload button from the dataset and use the setFieldValue on the dataset of the uploaded URL

IE

.then((uploadedFile)=>{
    $w('#dataset1').setFieldValue('image', uploadedFile.url)
    $w('#image1').src = uploadedFile.url
    $w('#image1').show()
})

This is because you have already uploaded the image so you just need to set the datasets column field value to the url of the uploaded image then when saved it will go through.

@rusty I cut my code to past it here, but I pratically do the same as you, with a preview before pushing SEND button. The logic and the code is the same.

@yisrael-wix :button connected to dataset, but it has been working for months (I’m going to provide the code…)

@Scott Purslowe
I get your point, so I should insert “setFieldValue” under the SEND button, but in this way I should change all input pages of my site and re-test everything. Based on the fact that this function has stopped working by its own, I believe that Wix is going to update some code to fix the bug.
Anyway, I’ll test your solution for sure. Maybe it performs better than the native version?
Thanks all for your help!

@digital-edge thanks a lot for the hint, for me it seems to work… so I’ll keep my fingers crossed it will stay that way also after another Wix update release :slight_smile:

I still wonder if the original issue is going to be fixed… @yisrael-wix will you pls let us know here?

Have a good day all!