Results 1 to 4 of 4

Thread: saving file using php

  1. #1
    Join Date
    Mar 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default saving file using php

    can u tell how i can dynamically save our web page like save as option....

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Like a backup script?
    Jeremy | jfein.net

  3. #3
    Join Date
    Mar 2009
    Location
    Florida
    Posts
    31
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default

    You could use curl and save the text output.

  4. #4
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I think perhaps what you are looking for is the fwrite() function.

    First of course, you'd have to understand the fopen() and flock() functions. Heres an example pulled out of the book, PHP 6 A Beginner's Guide.

    PHP Code:
    <?php
    // open and lock file
    // write string to file
    // unlock and close file
    $data "A fish \n out of \n water\n";
    $fp fopen('output.txt''w') or die('ERROR: Cannot open file');
    flock($fpLOCK_EX) or die ('ERROR: Cannot lock file');
    fwrite($fp$data) or die ('ERROR: Cannot write file');
    flock($fpLOCK_UN) or die ('ERROR: Cannot unlock file');
    fclose($fp);
    echo 
    'Data written to file';
    ?>

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
  •