Forum Moderators: coopster

Message Too Old, No Replies

file put contents function not working

         

dbarasuk

4:11 pm on Sep 20, 2009 (gmt 0)

10+ Year Member



Hi guys,

I used the next script to add content on a pdf and word document but unseccessfully

Here is my script:

<?php
$where = 'myfile.pdf';
$what_added = 'myname';
$result = file_put_contents($where, $what_added, FILE_APPEND¦LOCK_EX);

if(is_numeric($result) AND $result != 0)
{
echo 'The content was added successfully';
}

?>

If assigned an SQL file to $where, i could see the string 'myname' added to that sql file, however, if i assigned a PDF(.pdf) or word(.doc) file to the variable $where, nothing was added. Someone to help understand why?

Thanks

dreamcatcher

6:14 am on Sep 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you running PHP5?

dc

dbarasuk

11:22 am on Sep 21, 2009 (gmt 0)

10+ Year Member



Yes,
exactly PHP 5.2.9

eelixduppy

2:28 pm on Sep 21, 2009 (gmt 0)



Have you checked your error log? See anything there? Perhaps a permissions problem.

dbarasuk

10:53 am on Sep 22, 2009 (gmt 0)

10+ Year Member



If the file to write to was opened, i indeed saw an error, once closed, i got a confirmation that the content was added but could find nothing in the targeted file.

A question however: Can PHP really add content to a PDF file?

thks,
db