Can I use AppleScript to upload a file to a webpage open in Safari using drag and drop? I would like to create an AppleScript to open a specified URL in Safari, login automatically if that would be possible and then upload a file to a form that accepts drag and drop file upload.

Would it be possible to automate that event using AppleScript?
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