I am currently working on a php/html/javascript project. I have a form where when the user presses the submit button, it should run a javascript function and then afterwards
Change the action attribute to the address of the php script you're posting to. Call the javascript function in an onsubmit attribute instead of action. But you'll have to prefix it with a return statement.
That way if validateAddImage() returns false, the form won't be submitted. But if it returns true it will.