Get total page count of PDF file on Disk , Uploaded via the document Upload (File Name ) Field

I am developing an application which needs some documents / files like Video files, image files and PDF files to be uploaded
Also, when the file is uploaded I want to get the total page count and store it into table.
I have tried TCPDF , FPDF. I am not able to get / open / import the file though I know the path to the uploaded file (confirmed this)
I have used the same path to get duration of the video and that part is working fine. The PDF is also uploaded in to the same folder as the video (tmp)
I am writing the code in the validate event.
Now my queries for help as follows:

  1. Can we get the total page count for the PDF files uploaded to the tmp folder
  2. As of now I am using the validate event. I want to use the ajax event but there is not event which can be attached to the upload field type
    Thanks to all in advance
    Suresh