Pretty hard to read like this, screen shots work better due to having a decent looking layout if the code and errors etc. however for starters the insert seems to be outside the promise, this would mean it is
- starting upload
- Inserting record
- finishing upload
- Assigning the URL of the file to the variable
You need to put the insert statement within the .then of the button upload this way it will run AFTER the upload has finished.