Results 1 to 4 of 4

Thread: File Operation

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    266

    Question File Operation

    Hi,

    Please tell me what's wrong with the following snippet of code.


    [phpcode]

    <?php

    $total=100;
    $a=fopen("Thankyou.txt","w");
    fwrite($a,$total);
    fclose($a);

    ?>

    [/phpcode]

    I have got the following error messages:

    Warning: fopen(Thankyou.txt): failed to open stream: Permission denied in /home/amitnet/public_html/test.php on line 4

    Warning: fwrite(): supplied argument is not a valid stream resource in /home/amitnet/public_html/test.php on line 5

    Warning: fclose(): supplied argument is not a valid stream resource in /home/amitnet/public_html/test.php on line 6


    Please help.

    Thank you very much for help in advance.

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: File Operation

    make sure you have write permissions to the file Thankyou.txt. I assume you have shared webhosting on a *nix server.. so, just FTP into your server and right click on your Thankyou.txt file, and chmod it so that you have write permissions. If you don't know how, with most FTP clients you can right click on a file and either go to "Properties" or something that says permissions, CHMOD, or anything similar.. most FTP clients then ust give you 9 checkboxes, 3 for read, 3 for write, and 3 for execute. since your text file is not executable, you can leave the execute ones blank. you can check the 3 read and 3 write ones.

    this should rectify your problems.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    266

    Question Re: File Operation

    Thank you for your help.

    Please tell me how to set file attributes from php code.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: File Operation

    You can't. Not from PHP. You must do it from the FTP client.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width