[PHP] converting word document to plain text file

2005-04-20 Thread Cima
hi,

i need to store some files that contain text in my database. im planing to
upload the file using a php script. what id like is to be able to take the
info(text writen in the file) from the file and store it on a plain text
file and then store it since i plan to consult the info in these plain text
files later. the thing is that in case someone decides to upload a *.doc,
*.rtf or *.pdf, i dont know how to read such files to get the text from
them. is there a way to these types of files in php or some other way?

thanx.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] converting word document to plain text file

2005-04-20 Thread Andy Pieters
On Wednesday 20 April 2005 23:14, Cima wrote:

 them. is there a way to these types of files in php or some other way?


The easiest way is to tell your users you expect file format to be text only.  
You can test for mime type by using built-in php functions (and should do 
so!).

The hard way means that you need a parser for pdf, rtf, and doc files.  PDF is 
open format so there will no doubt be some PEAR module for it.  Rtf is quit 
ieasy to parse yourself, and doc is m$ propriety so that will be a lot more 
difficult to implement.

Or better, you might find a commandline tool that can do the job for you, and 
call that from within php.  Before doing so, please take at least one day to 
study security.  Since you provide your users with a way to transfer files to 
your server.  And you process those files then possibly users can hack your 
server.


When you got it working, report back here and ask us to analyze your code for 
pointers on how to make it more secure.

Good luck!


Andy

ps: Google is your friend!

http://www.google.com/search?num=100q=%22read+pdf%22+%2BphpbtnG=Search

Also search on PEAR
http://pear.php.net

-- 
Registered Linux User Number 379093
-- --BEGIN GEEK CODE BLOCK-
Version: 3.1
GAT/O/E$ d-(---)+ s:(+): a--(-)? C$(+++) UL$ P-(+)++
L+++$ E---(-)@ W++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
e$@ h++(*) r--++ y--()
-- ---END GEEK CODE BLOCK--
--
Check out these few php utilities that I released
 under the GPL2 and that are meant for use with a 
 php cli binary:
 
 http://www.vlaamse-kern.com/sas/
--

--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php