Web Devvy
Web Devvy

Reputation: 55

Can't make javascript object property value update

Not sure why I can't seem to update a value. I'm using a file uploader and I need to append an invoice number to the file name, so we don't get duplicate files.

Here is the code:

console.log(data.files[0]);
            console.log(data.files[0].name);
            console.log('$("#InvoiceNumber").val() =' + $("#InvoiceNumber").val() + "-" + data.files[0]['name']);
            //here I try to update 
            data.files[0]['name'].value = $("#InvoiceNumber").val() + data.files[0]['name'];
            //have also tried
            // data.files[0]['name'] = $("#InvoiceNumber").val() + data.files[0]['name'];
            //and
            //data.files[0].name = $("#InvoiceNumber").val() + data.files[0].name;

            console.log(data.files[0]);

The results from outputting to console are.

enter image description here

I can't change the file name server side, as duplicates exist. Anyone know why I can't update that value. Thanks

Upvotes: 1

Views: 49

Answers (1)

zerkms
zerkms

Reputation: 254926

File#name property is readonly. There is nothing you can do with it.

Upvotes: 5

Related Questions