Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2009
    Posts
    48
    Thanks
    28
    Thanked 0 Times in 0 Posts

    type in url search box and save contents in txt file

    Hi,

    I am trying to create a submit box that will allow users to enter a url and press submit. By pressing the submit button this will save the contents of the address in to a txt file. I can save the contents using curl but I have to specify the address in the same file. How do I write to the file so users can enter their own address and then the file should run and save the contents in a txt file.

    Here is some code I found at www.example.com

    $ch = curl_init("http://www.example.com/")
    $fp = fopen("example.txt", "w");

    thanks in advance

  • #2
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    4
    Thanks
    0
    Thanked 3 Times in 3 Posts
    To clarify what you say:

    1. User enter 'Google.com' in search box (I don't think it's search box. It's url to proxy, right ?)

    2. Then, before you give 'Google.com' content to user,
    you want to write html codes of 'Google.com' to file as google.com.txt

    Is it correct?

    I'm curious if it's useful 2 u ?


    ===================================
    Gotta love it - http://knowlege-free.blogspot.com

  • Users who have thanked webh4x0r for this post:

    tau9 (03-24-2009)

  • #3
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    PHP Code:

    $url 
    $_POST['url'];
    $filename str_replace(array('http://','/','.'),array('','_'),$url).'.txt';

    $content file_get_contents($url);
    file_put_contents($filename,$content); 

  • Users who have thanked NancyJ for this post:

    tau9 (03-24-2009)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •