SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member ferke's Avatar
    Join Date
    May 2003
    Location
    Hungary
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face File does not exist - why?

    Why writes the script 'does not exist' error? The file is exists on the local machine.

    My test code is:
    PHP Code:
    $filename "c:\\test\\test.txt";
    if (
    file_exists($filename)) {
        print 
    "The file $filename exists";
    } else {
        print 
    "The file $filename does not exist";

    Thanx!

  2. #2
    $postcount++; koomann's Avatar
    Join Date
    Feb 2003
    Location
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try:
    PHP Code:
    $filename "file:\/\/\/C:\/test\/test.txt"
    The directory would look like file:///C:/test/test.txt without the escaping \'s.

  3. #3
    SitePoint Member ferke's Avatar
    Join Date
    May 2003
    Location
    Hungary
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx but the error still exist. I tried

    file:\/\/\/C:\/dirname\/filename
    file:///c:/dirname/filename
    ///c:/dirname/filename
    c:/dirname/filename

    and none of them is working.

  4. #4
    $postcount++; koomann's Avatar
    Join Date
    Feb 2003
    Location
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe you need to capitilize the C?

  5. #5
    This is all Mumbo Jumbo Amit's Avatar
    Join Date
    Oct 2001
    Location
    New Delhi, India
    Posts
    277
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It should be $filename = 'c:\\test\\test.txt';

    HTH

  6. #6
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's what he had originally....
    Aaron Brazell
    Technosailor



  7. #7
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    'c:\\test\\test.txt';
    or
    'c:\test\test.txt';
    or
    'c:/test/test.txt';


    are all valid on win32 and case insensitive to boot
    is the file empty ?
    try is_writable() instead

  8. #8
    This is all Mumbo Jumbo Amit's Avatar
    Join Date
    Oct 2001
    Location
    New Delhi, India
    Posts
    277
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I meant, you should stick to
    $filename = 'c:\\test\\test.txt'; as file://c:/test/test.txt is usually used in case of urls on local browsing, not in case of file manipulation.

  9. #9
    SitePoint Member ferke's Avatar
    Join Date
    May 2003
    Location
    Hungary
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry

    I tried everything below but the error still exist.
    I want upload the txt file, then was error. Then I try fopen() function - error exist. And then tried file_exist() function finally.
    I was read php samples in php manual, but I can't open file in my local machine. Tech info: I have win98 osr2, and php ver. id 4.1.2. with apache on the server.


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
  •