using file_put_contents from pear

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Preminger

    #1

    using file_put_contents from pear

    Hello!

    We are running php 4.3.10

    Therefore I need to use php_put_content s through
    pear.

    Thats what my file looks like:
    <?php
    require_once 'php/Compat/Function/file_put_conten ts.php';
    $i=0;
    while ($i <= 5){
    $myArray[$i]="element position $i";
    print("dollar-i er nå lik $i<br>\n" );
    $i= $i + 1;


    }
    file_put_conten ts("array.txt" , $myArray);
    ?>
    Im not sure this is related to using a pear version or not, but I get a
    Warning: file_put_conten ts() failed to open stream: Permission denied

    Greatful to any clues!

    Thanks!!

  • Janwillem Borleffs

    #2
    Re: using file_put_conten ts from pear

    Michael Preminger wrote:[color=blue]
    > Im not sure this is related to using a pear version or not, but I get
    > a Warning: file_put_conten ts() failed to open stream: Permission
    > denied[/color]

    The dir/file must be writeable for Apache. Chmod the dir/file to 777 or make
    Apache the owner to accomplish this (Note: don't use PHP's chmod() function
    for this, but login to the server with FTP/SSH and peform the modification
    through the client.


    JW




    Comment

    • Michael Preminger

      #3
      Re: using file_put_conten ts from pear

      On 23.01.2005 23:05, Janwillem Borleffs wrote:[color=blue]
      > Michael Preminger wrote:
      >[color=green]
      >>Im not sure this is related to using a pear version or not, but I get
      >>a Warning: file_put_conten ts() failed to open stream: Permission
      >>denied[/color]
      >
      >
      > The dir/file must be writeable for Apache. Chmod the dir/file to 777 or make
      > Apache the owner to accomplish this (Note: don't use PHP's chmod() function
      > for this, but login to the server with FTP/SSH and peform the modification
      > through the client.
      >
      >
      > JW
      >
      >
      >
      >[/color]
      Thank you!

      Writing a file is now possible.
      I am able to write a file to a special directory that apache may write to.

      I actually wish to do the following:
      read a text file with the file() function into a text array,
      append a line to the array,
      and write back using file_put_conten ts() into the same file.

      this fails.

      Is the error due to the file not being "closed" after being read by the
      file() function?

      Thanks
      a lot!

      Michael

      Comment

      • Janwillem Borleffs

        #4
        Re: using file_put_conten ts from pear

        Michael Preminger wrote:[color=blue]
        > I actually wish to do the following:
        > read a text file with the file() function into a text array,
        > append a line to the array,
        > and write back using file_put_conten ts() into the same file.
        >
        > this fails.
        >
        > Is the error due to the file not being "closed" after being read by
        > the file() function?
        >[/color]

        Which error do you get? Normally, the following should work fine:

        $file = file($filename) ;
        $file[] = "a line\n";
        file_put_conten ts($filename, implode("", $file));


        JW



        Comment

        • Michael Preminger

          #5
          Re: using file_put_conten ts from pear


          Sorry to have bothered you. It was a simple file-access related problem.

          On 26.01.2005 00:07, Janwillem Borleffs wrote:[color=blue]
          > Michael Preminger wrote:
          >[color=green]
          >>I actually wish to do the following:
          >>read a text file with the file() function into a text array,
          >>append a line to the array,
          >>and write back using file_put_conten ts() into the same file.
          >>
          >>this fails.
          >>
          >>Is the error due to the file not being "closed" after being read by
          >>the file() function?
          >>[/color]
          >
          >
          > Which error do you get? Normally, the following should work fine:
          >
          > $file = file($filename) ;
          > $file[] = "a line\n";
          > file_put_conten ts($filename, implode("", $file));
          >
          >
          > JW
          >
          >
          >[/color]

          Comment

          Working...