read file .docx or .doc in php?

  • Permalink
  • submit to reddit
  • Email
  • Follow


SG93IHRvIHJlYWQgY2xlYW4gZGF0YSBmcm9tIC5kb2N4IG9yIC5kb2MgZmlsZT8KCiRmaWxlX3Vy
bD0iaHR0cDovL3d3dy5hYmMuY29tL3VwbG9hZC90ZXN0LmRvY3giOwokZG9jX2RhdGEgPSBmaWxl
X2dldF9jb250ZW50cygkZmlsZV91cmwpOwoKaXQncyBnaXZlcyBvdXQgcHV0IGxpa2UKCgYM77+9
VO+/vWHvv71i77+9bO+/vWXvv70g77+9Tu+/vW/vv71y77+9be+/vWHvv71s77+977+977+9HO+/
vRfDtgPvv73vv700w5YG77+9ASADbO+/vTTDlgbvv70BBQPvv73vv71hw7YD77+977+9Au+/vQvv
v73vv73vv70o77+9awrDtMO/w4Hvv70o77+977+9IO+/ve+/ve+/ve+/ve+/ve+/vTAGB++/vU7v
v71v77+9IO+/vUzvv71p77+9c++/vXTvv73vv73vv70C77+9DO+/ve+/ve+/ve+/ve+/vVBLAwQU
77+9Bu+/vQjvv73vv73vv70hCu+/veKAmsWgwrwTw7rvv73vv73vv70cAu+/ve+/vRPvv73vv73v
v71bQ29udGVudF9UeXBlc10ueG1sCgpob3cgdG8gZ2V0IGNsZWFuIGRhdGEgbGlrZSB0ZXh0IGZp
bGU/Pw==
0
Reply Amit 4/24/2010 10:14:57 AM

See related articles to this posting


Amit Prakash Pawar wrote:
> How to read clean data from .docx or .doc file?
> 
> $file_url="http://www.abc.com/upload/test.docx";
> $doc_data = file_get_contents($file_url);
> 
> it's gives out put like
> 
> �T�a�b�l�e� �N�o�r�m�a�l����ö��4Ö� l�4Ö���aö������(�k
> ôÿÁ�(�� ������0�N�o� �L�i�s�t���������PK�����!
> �‚Š¼ú��������[Content_Types].xml
> 
> how to get clean data like text file??

That's because it's not an ASCII file.  It's a binary format used by 
Microsoft Word.

If you're on a Windows server, you can use a COM object to open the 
file.  Otherwise, you'll have to find a PHP library which can read the 
document.  Goog luck - I haven't found one yet which doesn't have problems.

Your best bet is to just have Word save the file as a plain text.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
0
Reply Jerry 4/24/2010 10:35:55 AM

In article 
<d4872e43-e4e4-412d-83d7-a46bf62b0d9d@o15g2000pra.googlegroups.com>,
 Amit Prakash Pawar <amitppawar2007@gmail.com> wrote:

> How to read clean data from .docx or .doc file?
> 
> $file_url="http://www.abc.com/upload/test.docx";
> $doc_data = file_get_contents($file_url);
> 
> it's gives out put like
> 
> ?T?a?b?l?e? ?N?o?r?m?a?l????�??4�? l?4�???a�??????(?k
> ���?(?? ??????0?N?o? ?L?i?s?t?????????PK?????!
> ?��1�4�????????[Content_Types].xml
> 
> how to get clean data like text file??

This would require you knowing and decoding Word's proprietary format.  
Unless you got Microsoft's internal documentation off the net or reverse 
engineered the format, that's not going to happen.  Use Word to output 
the file in plain text.  Then you'll be able to read it.

-- 
DeeDee, don't press that button!  DeeDee!  NO!  Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]


0
Reply Michael 4/24/2010 4:58:33 PM

Op 24-4-2010 12:35, Jerry Stuckle schreef:
> Amit Prakash Pawar wrote:
>> How to read clean data from .docx or .doc file?
>>
>> $file_url="http://www.abc.com/upload/test.docx";

sorry, we couldn't find that page

is what they are responding at www.abc.com.....

-- 
Luuk
0
Reply Luuk 4/24/2010 5:02:52 PM

Luuk wrote:
> Op 24-4-2010 12:35, Jerry Stuckle schreef:
>> Amit Prakash Pawar wrote:
>>> How to read clean data from .docx or .doc file?
>>>
>>> $file_url="http://www.abc.com/upload/test.docx";
> 
> sorry, we couldn't find that page
> 
> is what they are responding at www.abc.com.....
> 

That's because the op doesn't know enough to use example.com.  He uses a 
real domain, instead.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
-1
Reply Jerry 4/24/2010 5:49:56 PM
comp.lang.php 32528 articles. 6 followers. Post

4 Replies
1697 Views

Similar Articles

[PageSpeed] 28


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Open folder, read file, close file, open new folder, read file close file etc....
Hello, My current directory has several folders within it. Each folder has the same type of file within it. How do i go from the current directory, into one of the folders, edit the file, then come out of the folder, then go into another folder, edit a file then come out of the folder then into a new one etc etc etc. If this does not make sense i apologise and will try to explain my problem a little better. Any help would be much appreciated. Cheers, Phil Phil: I'm not sure it makes sense. Personally I use the mouse and keyboard for doing this. Were you thinking of something else?...

File.read(fname) vs. File.read(fname,File.size(fname))
Hi, this is my first post on ruby-forum. Hope this is useful to someone! I have learned from experience to avoid reading files using File.read(filename)... it gives terrible performance on even moderately large files. Reading large files line by line is much faster, and uses much less memory. However, there are cases when you do want the entire file in a single string. I just discovered that you can do this MUCH faster with File.read(filename,File.size(filename))... check this out: > File.size(bigfile) # not really that big... just 10 MB => 10531519 > Benchmark.bm do |bm|...

PHP/IIS: File Read/Write OK, File Unlink Denied
Hi there, I'd greatly appreciate any insights into the following problem: I've got PHP running fine on IIS (OS: Server 2003, SP1; IIS: 6.0; PHP: 4.3.11). In PHP, the user uploads a file, which is then processed and the contents are inserted into a new file, created in PHP, onto the server. This bit works fine, the new file created by PHP is correctly stored. Later, once the user confirms the upload and PHP inserts the contents of the file into the DB, the code tries to remove the file created in PHP moments earlier, via the unlink() function. What I see on screen is the following...

cannot I search the doc's contents (doc=file.read) one more times?
Hi, I wanna retrive ip and its port from the html file which contains "<tr bgcolor=#e3e6ea><td>61.135.158.111</td> <td>80</td>",cannot I search the doc's contents (doc=file.read) one more times? doc=file.read #first get ip'es success ips=doc.scan(/(\d{1,3}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3})/) ips.each {|ip| puts ip } #then get ports still on doc ,but no one got nothing,if commentted above ip scans ,this would works. ports=doc.scan(/<td>(\d+)<\/td>/) ports.each {|port| puts port } file.close Thanks in advance! ...

Reading files into PHP
Hello, how can I read files into PHP. I can make a listing of a directory, but reading the file content into the PHP goes wrong. ==== script ========== <?php $handle=opendir('nieuws'); while (false!==($file = readdir($handle))) { if ($file != "." && $file != "..") { $fp = fopen($file,"rb"); fpassthru($fp); fclose($fp); echo $fp; echo "<HR>"; } } closedir($handle); ?> =========== Thanx, Marco J.L. On 2005-04-06, Marco J.L <luyendyk@yahoo.com.news> wrote: > how can I read files into PHP. I can make a ...

PHP and .doc Files
Hi all Ive searched around everywhere and I cant find the answer that doesnt involve being on a Windows Machine. Im wondering is it possible to read a .doc file? I know its a propietary MS thing however Open Office/Star Office not sure on others can read the file, I was wondering has anyone been able to accomplish this at all. Thanks. Paul wrote: > Hi all > > Ive searched around everywhere and I cant find the answer that doesnt > involve being on a Windows Machine. > > Im wondering is it possible to read a .doc file? I know its a > propietary MS thing however Open O...

how to read out the content of a file named domain.com/file.php?X=ABC
I need some help reading out files. Here's my problem: I have a website where several pages are accessed through PHP-variables, such as http://domain.com/file.php?content=abc http://domain.com/file.php?content=xyz "abc" and "xyz" also being the .txt-files that contain the content which is inserted into file.php through readfile(). So far so good. Now I'm working on a PHP-powered search script, which is supposed to read out the files and extract keywords. Therefore it has to open each file and get the contents into an array using file(). foreach ($file_ar...

String[] files = {"a.doc, b.doc"}; VERSUS String[] files = new String[] {"a.doc, b.doc"};
What's the differences between the following: String[] files = {"a.doc, b.doc"}; and String[] files = new String[] {"a.doc, b.doc"}; I think similar question as: String file = "a.doc"; and String file = new String("a.doc"); "Matt" <jrefactors@hotmail.com> wrote in message news:ba8a039e.0409160903.b7a3d23@posting.google.com... > What's the differences between the following: > > String[] files = {"a.doc, b.doc"}; > and > String[] files = new String[] {"a.doc, b.doc"}; > I think similar q...

Easiest way to read a XML doc from file, reformat it and write it indented to a second file?
Assume I have a XML docuemnt in file mydoc123.xml The XML doc is textually formatted as one long line/string without line breaks. Now I want to read this XML doc file into Java, then reformat it so that the hierarchy levels are indented in a human radble format "as usual". Finally the result should be written to another text file result.xml How can I do this most easily (preferable without third party libraries but only J2SE built-in functions)? Ray Raymond Schanks wrote: > Now I want to read this XML doc file into Java, then reformat it so > tha...

File reading; beginning read on line 9 of a file
Hello, I am trying to read a text file in Scilab which has a mix of text and numerical data for the first few lines and then becomes an easily readable numerical data file after line 9. I do not need any of the data in lines 1-9. I am trying to avoid specifying the format of the first 9 lines, which changes depending on the number of channels recorded, and then looping through and reformatting everything. Is there a simple way to open a file and advance a set number of lines? After deleting the first 9 lines, the read command works fine for my purposes. Any help appreciated. ...

2k file read vs 4k file read
I was just measuring the time taken to read small files and noticed that the time taken to read a 2k file is about 20% less than a 4k file read. But the time taken to read a 1k file is 10% more than time taken to read a 2k file. I made sure the cache was warm before I took the timings. I use time stamp counters to get the cycles. Does anybody know why? ( I am using the jfs of ext3 ). cheers Somu ************************************************************************* "I've never understood how God could expect his creatures to pick the one true religion by faith - it ...

[File]Reading a file
I am puzzled as the prog does not fin the file ; this is the code : JFileChooser chooser = new JFileChooser("/media/USER_data/dmoyne_data/GENEALOGIE_data/GenJ_data/GenJ_data/actes/Menotey/tmp"); int FileSelectorIntValue = chooser.showOpenDialog(null); if(FileSelectorIntValue == JFileChooser.APPROVE_OPTION) { String FileNameStringValue=chooser.getSelectedFile().getName(); println("You chose to open this file: "+FileNameStringValue); BufferedReader entree=new BufferedReader(new FileReader(FileNameStringValue)); String ligne; do { ...

Reading update from a PHP-file
hello everyone I'm looking for a good idea as to how to do the following: I have a JAVA client which calls a PHP script on a server via HTTP GET. Now the PHP script does a rather time-intensive task which can take a couple of minutes. I'd like to show the progress in my client GUI, i.e. through a JProgressBar. Now my question is: does anyone have a brilliant idea how to get the progress from the executing PHP-file? I was thinking about the PHP-file outputting an XML-doc - but I don't think that would work because I'd be getting incomplete XML-chunks... Any idea? thanks a lot ...

PHP Read Text File
Hey, read some tips/pointers on PHP.net but can't seem to solve this problem. I have a php page that reads the contents of a file and then displays the last XX lines of the file. Problem is this...whenever the file gets larger that ~5MB, the page just displays nothing, as though a timeout has occurred but I get no error. At 4.8MB (last confirmed size)...the function still works. Any ideas what code below is lacking?? <? $handle= fopen("/var/log/myfile", "r"); if ($handle) { while (!feof($handle)) { $arrLog[] = fgets($handle, 4096); } fclose($handl...

Reading a file FileReader, doesn't read a file
Hello I wanted to write a simple program that gets a string from a file. But i don't know where to put the file that i could read it. I puted the plik.txt file in the package where my Main class is. I UseNetBeans if that makes a diference. Here is my code. package czytaniezpliku import java.io.*; public class Main { public static void main(String args[]) { try { String wejscie; BufferedReader br =3D new BufferedReader(new FileReader("plik.txt")); //FileReader we =3D new FileReader("pliki/ plik1.txt"); ...

read file txt by php
sorry for my english, I would to read a txt file and to extrapolate only some data for to publish on the html page how first step i try to read and publish the file in this mode: <? $var=fopen("test.txt","r"); //Apro il file di testo $leggi=fread($var,filesize("test.txt")); $sss=nl2br($leggi); fclose($var); echo $sss; ?> this is the structure of the my file: INFO 2008/03/04 09:37:55.561 ; source=local; msg="xxxxxxxxxxxxx"; alerttext="kkkkkkkkkkkk"; date="Mar 04 09:37:55 2008"; END I would want to only extrapolate follow...

Not reading the php.ini file
I have php 4.3.3 on my local IIS5.1 server (XP) in ISAPI mode. It all works ok except that it does not seem to be reading the php.ini file as any changes I make are not shown up when doing a phpinfo(). This shows the ini path as c:\windows\php.ini. This is where it is and it is the only php.ini on the machine. I have tried stopping and starting the service but this does not help. Any advice on why it does not seem to be being parsed? "Ian Pawson" <ian@ipawson.com> wrote in message news:3f6b5681$0$245$cc9e4d1f@news.dial.pipex.com... > I have php 4.3.3 on my local IIS5.1 s...

Reading and writing files in PHP
Hello, I have a question about how PHP handles multiple file reads/ writes. I made a page containing a self-submitting form where the user can type his name, topic and a text. When he submits the form, PHP reads the .php file in a variable. It then processes it: adds the user comments to the var and writes the modified file back to disk. Next time the user opens the page (s)he sees te comments (s)he and others added. So what I have is a very simple 'Blog' without using a database. The ..php file is modifying itself every time a user submits something. Questions > What happens when ...

Reading PDF Files with PHP
This is probably a more appropriate location to post this question. I should have know that since I've found most of the other PHP/PDF information contained in this group. Here's my issue...I will from time to time receive 4 - 5 PDF files into a directory; I want to be able to schedule a task which will pick up these 4 - 5 PDFs, read through them and then generate 1 pdf. Creating PDFs in PHP is obviously fairly easy, however I haven't found anything yet that will actually read the PDFs so that I can then place that content into this new single file. Can this be done with PHP. Any ...

I need to create html files from php files using php
I am very new to PHP, although I have been using ASP for a few years. I use a product in ASP called ASPTear, it's a small dll that my hosting company happens to have loaded. Basically you can set up a function that you can pass an ASP page to and it will read the ASP and write out an HTML file. I use this to save load on the server and speed up my site, I have a few include files that look up data and then present it, this data does not change very often, so I run a routine called rebuildhtml.asp that will call a few ASP files and create HTML versions. I am now converting the site to P...

file.read() doesn't read the whole file
Hi, >>> snapdir = './mango.txt_snaps' >>> snap_cnt = 1 >>> block = 0 >>> import os >>> os.chdir('/mnt/gfs_local') >>> snap = open(snapdir + '/snap%s/%s' % (repr(snap_cnt), repr(block)),'r') >>> snap.read() 'dfdfdgagdfgdf\ngdgfadgagadg\nagafg\n\nfs\nf\nsadf\n\nsdfsdfsadf\n' >>> snapdir + '/snap%s/%s' % (repr(snap_cnt), repr(block)) './mango.txt_snaps/snap1/0' The above code works fine and it reads the whole file till EOF. But when this method is used in a different s...

reading a .txt-file with php
Hello NG, I have the following problem and it would be nice, if someone could help me out on this problem: Thanks for your help! Jules Bach content of file.txt #1: Michael #2: Dennis #3: Karl the following file writes only the first line of file.txt: <?php $fp = fopen("file.txt","r"); if ($fp) { $line = fgets($fp, 100); echo "$line<br><br>"; fclose($fp); } ?> Now I would like to have a PHP-file, which can write every line in different orders (the order should be write in the PHP-file) for example: #2: Dennis #1: Michael #3: Karl is...

PHP read from file on server
Hello, I'am new PHP student and ( programmer ? ). I want to sell my software online but how can I create to PHP read from file on server with cd-keys on my server and send them to user e-mail. And delete sent cd-key ( first line ) after sent delete? Regards, Vedran ...

Reading a spreadsheet file with the Read assistant
I'm using the assistant to read a comma delimited spreadsheet file but it won't close the file when it is done, unless I close/stop the VI.&nbsp; If I don't use the assistant the file closes fine.&nbsp; I need to do this in order to open the file (not as read-only)&nbsp; for other programs while the VI is running. &nbsp; Thanks Sorry, I am unclear what you mean by "assitant". Are you talking about the express VI? In any case, reading a comma delimited file is pretty simple, just use the plain file I/O finctions and set the access options as desired. Than...