Hi -
I need to create a file on the server that is named $foo, $foo being a form field captured on form submit.

fwrite() is what I've been using to write into files that already exist on the server. Now, I need to be able to create a file and then write into that file with the same script. If the file exists, I will write into the existing file.

There was another thread in this forum that addressed the question but the answer was off topic ;-)

Thanks for assistance in advance!!

jloch

    When you call fopen() with 'w','w+','a' or 'a+' it will try to open the file, and if it does not exist it will attempt to create it.

    $foo = 'blah';
    $file = fopen($foo, 'a');

    This will attempt to open the file named 'blah' for writing, and if it does not exist it will try to create the file.

    Hope this helps 😉

      Thank you for the help - you saved me time and headaches!!

      jloch

        You should download a copy of the manual. It saves a lot of time having it as a reference.

          I searched the manual for a specific answer to my question, didn't find it, posted here and got my answer in 5 minutes.

          Thanks for the advice, though!

          jloch

            Write a Reply...