fopen function is not working in "W" mode in php

Discussion in 'PHP' started by hardik, Jun 29, 2007.

  1. #1
    hai all

    when i try create new file using fopen function in php in "W" mode. it dose not create file.

    Create test.php file in /var/www/html/ directory on linux machine.

    past this simple code:

    <?php

    $fp = fopen("newfile.file", "w") or die("Couldn't create new file");

    ?>

    through firefox browser run above file:

    ip address/test.php

    example : 192.168.0.115/test.php

    it show Couldn't create new file means not create file.

    please any one tell me step how to run this file using browser on linux.

    thanks in advance
     
    hardik, Jun 29, 2007 IP
  2. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you have to chmod the folder and the file you want to work on.
    chmod determines the operations a user can do on a certain file/folder. For instance 0777 means that any user/group/administrator can read,write and execute the file

    so if you want to get your code working, try adding these lines:
    chmod ( 'folder_that_contains_my_file', 0777 );
    chmod ( 'myfile.file', 0777 );
    PHP:
    or if it's only this file, use an ftp manager to chmod that specific file and folder
     
    UnrealEd, Jun 29, 2007 IP
  3. hardik

    hardik Guest

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hai dear

    i done this already. but still it is not working.

    i know about file permission.

    after adding two line give by u.

    it is not working and show same error.


    thanks for your reply
     
    hardik, Jun 29, 2007 IP