Django - Upload PDF and Excel file to mysql database

70 views
Skip to first unread message

Sainath Bavugi

unread,
Aug 15, 2018, 5:48:48 AM8/15/18
to Django users
I have written a code to upload an excel sheet and save the contents to MySQL database. Below is the code to upload the file in memory.
form = UploadFileForm(request.POST,request.FILES)
if form.is_valid(): file_in_memory = request.FILES['file'].read()
   wb
= load_workbook(filename=BytesIO(file_in_memory), data_only=True)

Now, I want to upload a PDF file and save the path to the MySQL database using the same function. For instance, If excel has record A then there is an associated PDF file which I have to link. How do I handle this situation? I am aware of multi-file upload but I assume that will save the file path to the database directly.

Reply all
Reply to author
Forward
0 new messages