Hi guyz, i'm working on a site, and i need some help on a php code for advanced file reading.

I need to implement a php code that will intelligently read the contents of a file.

When users upload the required type of file to my website,
it will read the file, and get the contents of the file,
and the contents of the file will be stored in a database.

The type of file that will be uploaded by the user to the website will be:
word documents: .doc .docx
adobe document: .pdf
text docuemnt: .txt

When the file is uploaded it will read the file, for example,
When a Job Cover Letter is uploaded:
It will read/check for date in the file
It will read and check for the applicant name, which will normally be the last text in any cover letter, or second to the last.
It will read and check for the position the applicant is applying from,
It will even be able to search the contents of the file, for specific keywords,

I need to know how i will go about this webapp in php,
if it is fgets i'll use, or perhaps there are other methods i can use.

Thank You.

So what have you done so far?

This is pretty easy... all you have to do is make sure you have the proper php extension installed..

For text reading use.. fread function.

For PDF reading make sure you have http://www.foolabs.com/xpdf/about.html installed as php extension.
For DOC reading use this http://www.winfield.demon.nl/...

To read pdf file using php script, you can try something like this

$xpdf_location = 'usr/local/bin/xpdf__pdf_to_text'; //not sure, you will have to read the manual
## depending on your pHP installation.. usr/bin/ can also be valid.. it all depends on the actual installation

## define the location of the pdf file to be read
$pdf_file = 'uploads/somefile.pdf';

## execute the the xpdf as you wish

$thisPdf = @exec($xpdf_location, $pdf_file.'_');

## for debugging purposes remove the error  (@) supressant above..

print($thisPdf);

## for the Doc
$doc_location = 'uploads/somedoc.doc';

$thisDoc = @exec('docReader_location','docFilename');

print($thisDoc);

For additional reading, make sure to search for error reporting on PHP triggered exec command or shell exec.. this should be able to give you a line by line error report just in case something is not working properly in the back-end.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.