Hi I have a project ,that required a user to enter URL for any site, then I will save the HTML page for this site in my server (like brwser “save as” in client side) how can I do that?
I searched for it in php and JS ,but I can’t find any thing
can you help me ,please?
With PHP this task is really simple:
[php]<?php
$content = file_get_contents(‘http://mysite.com/myfile.html’);
file_put_contents(‘files/myfile.html’, $content);
?>[/php]
Just a few notes for the example above:
- directory ‘files’ need to be availble for writing by php
- option allow_url_fopen must be turned On in your php.ini
- this will work with PHP 5 (if you have PHP 4, use fopen(), fwrite(), fclose())