I can see two problems on the page. The main issue that your add to cart is not working is because you are not submitting the add to cart form. Instead you have a separate form for the file field and this is the form that is being submitted. You will need to combine this form with the add to cart form just after it.
Along with moving the file field into the add to cart form you will also need to make sure it has a valid name and id. Finally, you will need to update the trigger for the upload to work with the add to cart button being pressed.
The other problem that I can see may not be affecting things but the server side code on your page is inside of the html code, it should be above it. You should move lines 65-151 to be just after line one. This is the proper place to put the server side code.