emile 12 months ago
parent da306d87b6
commit e77ce16f32

@ -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 = {

@ -113,7 +113,7 @@ small {
<input type="file" id="fileupload" name="files" placeholder="Select file" multiple class="opacity-0 absolute top-1/2 left-1/2 w-[25px] -translate-x-1/2 -translate-y-1/2 z-10">
</div>
<select id="filePathInput" name="filePath" hidden></select>
<select id="filePathInput" name="filePath" multiple></select>
</div>
<div id="uploaded_files" class="w-full flex flex-col gap-3 top-0 right-0 inset-0"></div>

Loading…
Cancel
Save