I am uploading the pdf file in django form.
But i need to perform the validation on the pdf file by reading the contents of file and then checking and if its not valid then give some error message.
But i am not able to find how can i get the pdf file location so that i can read the file and do some test.
I don’t want to first save in temp location and then do validation and then delete the file
all i need is the path of the file so that i can run some system command on the file
The example below is based on the Basic file uploads example in the django docs. You can have a function in this example called check_pdf that does your validation on the pdf file and returns true/false based on whether it is valid. Depending on that you redirect the user to a success or invalid pdf page. This is the simplest way of doing it. You could do more and present specific error messages using the forms apis.