0

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.

3
Contributors
2
Replies
15
Views
4 Years
Discussion Span
Last Post by veedeoo
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.