I have a problem with word documentation generation when generating a word document (docx) with PHP. I am doing this for security reasons, as I do not want people to be able to directly access a file with urls, so I store the files above the web root and they are generated on the server side on demand. Here is my code for manually testing file generation of a .docx file ( a Word 2007 file ):
$path = "../../uploads_productionization/file_for_category_1_tab_2/adsfdafds.docx
// We'll be outputting a docx
header( 'Content-type: application/vnd.openxmlformats & -officedocument.wordprocessingml.document.main+xml');
// It will be called downloaded.docx
header('Content-Disposition: attachment; filename="downloaded.docx"');
// The word source is in adsfdafds.docx
readfile($path);
When I execute this code, ie when I manually generate a docx file, I get two error messages:
"The Open Office XML document cannot be opened because there are problems with the contents"
Details: "File is corrupt and cannot be opened"
Next message:
"Word found unreadable content in downloaded.docx. Do you want to recover the contents of this document? If so, please click Yes"
When I click Yes on the second message, the document opens. Sometimes the file is okay, sometimes it isn't when there are pictures and formatting and so on and so forth.
Anyone have a solution for this problem? Been trying to get around this for at least a week...
P.S. All other files, PDFs, text files, work fine.. I think it's just office documents.
Print 'a' to 'z' via for loop
A very simple problem..How Can I print a to z NOT a to y ?It is a part of a code where | $alpha= 'a';for($alpha='a';$alpha!='z';$alpha++){echo $alpha.' ';} Output: a b c d e f g h i j k l m n o p q
how can we add data from dynamic fields to mysql db in php
i have a script which i found on the internet. i modify that script according to my needs. what is in that script is there are three form fields with two buttons. one button is "Give me more
Structure Question - One Table or One Table Per Record Set?
I have a web app (mySQL and PHP) which allows people to create an item with up to 200 records which I store in a single table. Any user subscribing to that item will be pulling up to 4 records from
SQl num_rows problem
when i try to count rows from an SQL select i get an warningCode: [Select]$countviews = mysql_query("SELECT * FROM viewed WHERE sfw = '0' AND cookieid = $id");$num_rows_viewed =
New to PHP and just trying to understand a little code.
I hope I'm not annoying anyone or breaking the rules but I was wondering about this bit of code right here: " <?php$people = Array(Array('name' => 'Kalle', 'salt' =>
Best PHP Documentation generator
Hello guys!I would like to hear from you what is the best PHP documentation generator. Personally I use PHPDocumentor.What about Doxygen? It seems that Doxygen and PHPDocumentor have a very slight
Unexpected T_Variable ?
Hi all,I dont really know what I am doing!! I know I'm doing something wrong, and I know its on line 42 "$sql="select pname, award, aw_year" but I dont know why its a problem?? Can
Send inserts to mysql thru port 80
Hi!I have an application that must do some inserts in a mysql db. This db is behind a firewall, and only port 80 is available.My first thougt is to use xml or csv, and in some way parse that using
Format timestamp from mysql
When I tried this:Code: date("m/d/Y H:i A", $row['timestamp'])I got 12/31/1969 18:33 PM, so I know the time section is working at least. How can I get the mm/dd/yyyy section to work
PHP5/Zend 2.0 - Resources
PHP5 Snapshots