at line 64, the trigger for the upload is the Submit order button being pressed:
if(isset($_POST["Submit_order"]) || isset($_POST["Submit_order_x"])){
it needs to be the checkout button being pressed:
if(isset($_POST["Checkout"]) || isset($_POST["Checkout_x"])){