Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 5 of 5

This is a discussion on creating a file in the Shared & Semi-Dedicated forum
i am trying to create a file, without success my code: PHP Code: <? $tmp  =  tempnam  ( "/neo.nocdirect.com/public_html" ,  "tmpFile" ); $fp  = @ fopen  ...

  1. #1
    JPC Senior Member
    Join Date
    Mar 2003
    Posts
    74

    creating a file

    i am trying to create a file, without success my code:
    PHP Code:
    <?
    $tmp 
    tempnam ("/neo.nocdirect.com/public_html""tmpFile");
    $fp = @fopen ($tmp"w");
    if (!
    $fp){
              die(
    "no");
    }

    fputs($fp"hi\n");

    @
    fclose($fp);
    ?>
    when i ftp in i cannot see the file

    how can i do this to make it work? cheers

  2. #2
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    The correct path to use to get to your public_html directory is /home/username/public_html, where username is your CPanel login name.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  3. #3
    JPC Addict randyriegel's Avatar
    Join Date
    Jan 2002
    Location
    Wintersville, OH
    Posts
    161
    I tried it with /home/myusername/public_html and it created the file in /tmp. PHP manual says this is normal behavior with older versions of PHP (prior to php 4.0.6). Now I'm wondering why this is still happening if since we're running 4.3.2.

  4. #4
    Loyal Client
    Join Date
    Sep 2001
    Location
    Wichita, KS
    Posts
    1,647
    is the directory properly chmodded?

  5. #5
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    Originally posted by mattsiegman
    is the directory properly chmodded?
    Matt makes a good point. PHP runs as nobody, so in order to write to your public_html you'll need to change the permissions on the directory. However, I'd recommend saving the file to some place either outside of public_html or in a subdirectory of it. Making your entire site world writable is asking for trouble...

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

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
  •