diff --git a/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc index e5707d36..bff5e65a 100644 Binary files a/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc and b/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/osinacore/add/views.py b/osinaweb/osinacore/add/views.py index 32516457..c3f07d27 100644 --- a/osinaweb/osinacore/add/views.py +++ b/osinaweb/osinacore/add/views.py @@ -673,20 +673,20 @@ def add_ticket(request, customer_id): ticket.save() ticket.departments.set(departments) - if request.POST.get('filePath'): - file_path = request.POST.get('filePath') - - # Check if the file exists - if os.path.exists(file_path): - with open(file_path, 'rb') as f: - ticket_attachment = TicketAttachment( - ticket=ticket, - file_path=file_path - ) - ticket_attachment.save() - else: - # Handle the case where the file does not exist - print("Error: File does not exist at the provided path:", file_path) + if request.method == 'POST': + file_paths = request.POST.getlist('filePath') + + for file_path in file_paths: + if os.path.exists(file_path): + with open(file_path, 'rb') as f: + ticket_attachment = TicketAttachment( + ticket=ticket, + file_path=file_path + ) + ticket_attachment.save() + else: + print("Error: File does not exist at the provided path:", file_path) + return redirect('ticketdetails', ticket_number=ticket.ticket_number) context = { diff --git a/osinaweb/osinacore/templates/add_templates/add-ticket.html b/osinaweb/osinacore/templates/add_templates/add-ticket.html index e18f38e7..e622adf1 100644 --- a/osinaweb/osinacore/templates/add_templates/add-ticket.html +++ b/osinaweb/osinacore/templates/add_templates/add-ticket.html @@ -113,7 +113,7 @@ small { - +