Results 1 to 7 of 7

Thread: How can I write to files using PHP?

  1. #1
    Join Date
    Feb 2005
    Posts
    16

    Default How can I write to files using PHP?

    Hi,

    the php code below doesn't work:

    Code:
    $file=fopen("test.txt","w");
    fwrite($file,123);
    fclose($file);
    I got an error msg like this:

    fopen(test.txt): failed to open stream: Permission denied in...

    Could someone please tell me where is my mistake?

    Thanks.

  2. #2
    Join Date
    Feb 2005
    Posts
    12

    Default

    thats a problem with permissions, so you'll need to use your FTP prog or shell access to CHMOD the directory test.txt will be in to 777. That understandable? Also, I set the "w" to "w+" just to be sure :)

    hixy

  3. #3
    Join Date
    Feb 2005
    Posts
    16

    Default

    Thanks, it really works!

  4. #4
    Join Date
    Feb 2005
    Posts
    12

    Default

    no problem

  5. #5

    Default

    writing and loading scripts often don't work at the beginning on a newly configured server because of the MOD's, like the CHMOD...
    The bizhat server just gives permission to give a file the CHMOD the status 777
    other servers have a cgi-bin directory where the standard status is 777...
    All work the same...

  6. #6
    Join Date
    Dec 2004
    Posts
    40

    Default

    I can't writing onto files even in my own PC,
    I can only using 'r' for txt file reading,
    how can I change my permission for php?

  7. #7

    Default

    Firstly, do you have php enabled on your account?
    Second, php does only work on a single computer (without a server) if you install a virtual server like phpdev.
    The permission within your analog server (webserver, Bizhat.com or something) should be 777. if you have an ftp-uploader you will have access to these controls by right-click, and in the popup-menu choose "permissions"...change it to 777and your problems are over.
    For the manual stuff about writing to files, please check out some php learning stuff, mentioned in one of the other topics. Just use the search link and search for php-codes

Bookmarks

Posting Permissions

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