Can I use AppleScript to upload a file to a webpage open in Safari using drag and drop?
It is going to be a headache to attempt to do this is automator or applescript, i would recommend using python with the splinter library, it is much easier to use then objective c or swift for this. Here is a link, https://splinter.readthedocs.org/en/latest/

It is possible to set it to run 100% in the background with a hidden browser or get it to open up something like firefox for you :P should be doable in under 10 lines with python, python comes preinstalled with osx and the splinter lib is easy to add into it with pip