I'm trying to use the fwrite command to write a new text doc to my local c: drive -

$filename = 'c:\xxx.txt';
$handle = fopen($filename, 'a');
fwrite($handle, $info);

this seems to be the obvious way to do this, but it's not working - furthermore, I've heard mixed reports about whether it's even POSSIBLE to write a new txt doc to your local machine.

Can anyone help? i'm not sure if i'm unaware of how to do this correctly, or if I'm just barking up the wrong tree.

    that's the thing, no error message - the text file "c:\xxx.txt " appears in the root of my website.

    Note that my code specifies the file to be created as "c:\xxx.txt" - using double \. ....

    ideas?

      You could try 'c:\xxx.txt', 'c:/xxx.txt', "c:/xxx.txt", or "c:\xxx.txt", any of which should work, although 'c:\xxx.txt' should work, too (it does for me).

      No messages, and you have error reporting and display on?

      Edit: You say the file appears in your folder. Does that mean the script is creating it? What do you mean by "not working"? And "c:\" isn't the root of your website, is it?

        I'm going to sit down and try each of the combos that you just listed -

        as for error reporting, I've recieved 'safe mode' restrictions over the last few days as I've experimented with this script, so i assume that error reporting and display are both on, however, i don't know how to check.

        lastly, the file appears in the directory on my server, which is not on the root c drive, named

        'c:\local.txt' 6.74 KB apache

        due to the web-unsafe characters, you gatta view it thru this url:
        http://www.nickad.com/c%3A%5clocal.txt

        you can see, it's there - being created dynamically! what a bummer.

        Like I said, i'll try the different combos that you listed. Remember, a really puzzling part of this is that my script was written to create 'c:\xxx.txt' (with TWO \'s, not ONE, which is what it turned out).... weird huh?

        and you said that it works fine for you?

          Are you uploading this script to a remote server and trying to get it to save the file your script generates to your local PC?

          If so...you can't. You would have to have the file generated onto the server, then downloaded onto your local machine.

            After some testing, i've found the following results -

            'c:\xxx.txt' creates a file on the server called "c:\xxx.txt "

            'c:/xxx.txt' doesn't seem to create a file anywhere

            "c:/xxx.txt" spits back the error message "Warning: fopen(c:/xxx.txt): failed to open stream: No such file or directory in /home/virtual/site397/fst/var/www/html/local.php on line 35
            Cannot open file (c:/xxx.txt)"

            finally, "c:\xxx.txt" creates the file c:\xxx.txt.

            Kudose says that it's not possible, but Installer says it works for him - maaaaaan, my head is spinning.

            so - if you have gotten it to work, i should be able to test it, right? can you link me to a php page that can leave a txt doc on my c drive? if so, you get 12 points, and Kudose has to say "you're smarter than me, Installer." - if not, then kudose gets 3 points by default.

            -andy

              I could be wrong, but I was under the impression that ActiveX and VB where the only two languages that could write data from the server locally.

              If I'm wrong, I would like to see a demo script too.

              🙂

                but Installer says it works for him - maaaaaan, my head is spinning.

                Installer said that because he assumed you realized you can only use fwrite() to write to files to the computer on which the webserver is running, not the viewer's computer (assuming they are not on the same LAN/computer).

                Kudose says that it's not possible,

                Kudos to kudose, he is correct.

                  welllllllllllllllll -
                  i'd rather be shot down then left hanging.

                  thanks for the feedback guys.

                  my goal is to generate a LOT of text files... i'm thinking a few thousand. i was hoping to keep that off my server, but i guess it's all the same, eh? I hope my host doesn't freak out or anything.

                    i'm thinking a few thousand

                    :eek: ! Umm... you can't combine them? Use a DB? Ehh... have fun!

                      Interesting developments while I was gone.

                      Yes, I assumed you were trying to write to the server's hard drive (your misuse of "local" threw me off). No, you can't directly write to the client's drive.

                        Well in theory he could setup a FTP server on the client machine, and use the PHP ftp functions to send the files from the server to the client once they are written, then delete them off the server...

                        It could be used to mimic directly writing to the client machine.

                          Write a Reply...