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 32516 articles. 6 followers. Post

4 Replies
1625 Views

Similar Articles

[PageSpeed] 52


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

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! ...

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...

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...

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...

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...

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 ...

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 ...

How to read strings from a doc file
Try to read strings from a doc file (windows word doc) data=fscanf(fid,'%s',1) however the data show strange characters. It needs to convert doc to plain text format. Is there a way to read strings from a doc file? In article <fem8a1$d4j$1@fred.mathworks.com>, Roy Chang <tigermacross@yahoo.com> wrote: >Try to read strings from a doc file (windows word doc) >data=fscanf(fid,'%s',1) >however the data show strange characters. >It needs to convert doc to plain text format. >Is there a way to read strings from a doc file? Windows .doc files are bin...

how can i read .doc files
hi all, Here is a small doubt with which iam struggling,The problem is how can i read .doc files and display content in browser in php.ok i have done it with file() and file _get_contents() but iam getting content with some meta characters like boxes etc. please solve this problem and reply me immediately it i surgent. Thanks & Regards Kalyan Kumar R > please solve this problem and > reply me immediately it i surgent. This sounds like you are demanding that I solve your problem. That is rude. Replying to you instead of to the group only helps you instead of helping everybo...

PHP and Reading Linux Text Files
let's say i have a linux text file located and named... /var//status/info it has a "0" or a "1" in it to indicate on or off. can php read this file even though it isn't in the apache html directory tree? if so, how is this done? tia... "Skeets" <skillet3232@yahoo.com> wrote in message news:1140195590.341963.7660@g44g2000cwa.googlegroups.com... > let's say i have a linux text file located and named... > > /var//status/info > > it has a "0" or a "1" in it to indicate on or off. > > can php read this ...

snow leopard and reading .doc files
Hi, I just installed snow leopard and can no longer read .doc files. Does it no longer come with an application to read ..doc files? If it doesn't, any suggestions for free downloads that will? Thanks for your help. Ken On Oct 15, 12:14=A0pm, "kquir...@yahoo.com" <kquir...@yahoo.com> wrote: > Hi, > > I just installed snow leopard and can no longer read .doc files. > > Does it no longer come with an application to read > .doc files? If it doesn't, any suggestions for free > downloads that will? > > Thanks for your help. > > Ken I me...

how to read tar.gz files from php
I need to deflate a tar.gz file, using php, and i have no shell access, please, im using php 4.3.11 on a iis 5.0 (i know, i sucks), i need to know weather or not thats possible thanks in advance. /f3l f3l_ wrote: > I need to deflate a tar.gz file, using php, and i have no shell access, > please, > im using php 4.3.11 on a iis 5.0 (i know, i sucks), > > i need to know weather or not thats possible http://pear.php.net/package/File_Archive ...

Saving CSV file to read from php
Hi, Let me explain what I am trying to do first. I want to upload a .csv file from a form page to the redhat server. Uploading is working fine, I could upload the .csv file to the server. But when I open the uploaded file using VI editor in the server, I see "^M" characters and all CSV formats are disappeared. Also "fgetcsv()" function cannot tell the length of the columns because of the messed CSV forrmats. When I saved the .csv file as Windows format in MS Excel, oh I am using MacBook, it keeps CSV format at the server, but php cannot access the file. Anyone have solut...

Reading Excel files using PHP
Hello there, Could someone pls give me pointers (or examples) on how to use PHP (installed on a linux) to read & write MS Excel spreadsheets. So far I've been converting a spreadsheet to text (as tab separated values) and processing the text file. I'm wondering if I can avoid this step and process the .xls file directly. I found a thread in this group - related to this topic - but it says, MS excel needs to be installed on target machine to use PHP's COM. I assume he's talking about PHP running on windows target machine. How can I use a similar approach on linux machine? ...

how to read and write any .doc file through java
Hi; all I have one assignement.I have to read and write .doc file through java code .I am not getting any api for this requirement.I have checked POI(Jakarta) api for this but i found that this is under development. Thank in advance You may want to look at how JEditorPane works to display RTF, it may help. http://groups.google.com/group/java-software-develoupment?hl=en On Tue, 1 Apr 2008 02:32:09 -0700 (PDT), narayan jaiswal <jaiswal.123@gmail.com> wrote, quoted or indirectly quoted someone who said : >I have one assignement.I have to read and write .doc file through >...

Need scroller that reads a php file
I need a scroller (java) or whatever that can read a php file and display it in the script. Does anyone know of any? I have searched the script sites but didn't find anything. John wrote: > I need a scroller (java) or whatever that can read a php file and > display it in the script. Does anyone know of any? > > I have searched the script sites but didn't find anything. > > > > Why are you asking for a Java scroller in a PHP newsgroup? Just because you're displaying PHP makes no difference. You could be displaying "War and Peace". -- ...

reading files with accents in the filename from PHP
Hello comp.lang.php, How can PHP open files on the local filesystem that contain certain characters, like umlauts, accents, etc? I am currently developing on Win2008 with PHP 5.5.1 (CGI/FastCGI). So the underlying filesystem is NTFS. Files with names like the following are inaccessible: ierl�nder.pdf Eug�ne.pdf etc. All files without these characters ARE readable. I test with: $bIsReadable = ((file_exists($path)) && (is_readable($path))); and these kind of filenames ALWAYS return false. The files with the troublesome names open fine with a PDF reader.) (It wo...