Click to See Complete Forum and Search --> : Can php download from the internet?


urquanmaster
01-03-2007, 02:11 PM
I'm just curious if php can upload web pages from the net into a specified directory. If so, could someone point me to a good book or tutorial on the matter? Thanks for any info :)

NightShift58
01-03-2007, 02:31 PM
With PHP, you can upload from your PC to a Server, using a combination of basic HTML and PHP (See: http://www.webdeveloper.com/forum/showthread.php?t=101466).

You can also transfer files from one server to another using FTP functions (See: http://www.php.net/manual/en/ref.ftp.php).

And of course, download from the Web to your PC, although that's more HTML than PHP.

urquanmaster
01-03-2007, 02:52 PM
Thanks for the links, but I can create an upload form and have done it a couple times.

What I'm actually trying to create is a gateway so that people can go to my computer, submit the URL they want, then PHP fetches the page from the internet and it's linked images/files, and then changes the urls in the html doc and dumps it into a new folder that users can access, then directs the user to it. Basically, this is a gateway to bypass office security and IP blockers. What I want to know is if I can use PHP to download an html document to a directory from the server.

I know something like this probably exists and is probably much better than what I'd ever do (not to mention the security bugs mine would have), but I want to use this as a learning project.

NightShift58
01-03-2007, 02:57 PM
Take a look at http://cr.php.net/manual/en/function.file-get-contents.php

svidgen
01-04-2007, 01:10 PM
My brother actually asked me this same question for the same purpose. To show him that it was possible relatively easily with PHP, I banged out a short PHP script as a demo:


<?php
include('http');
$site = $_GET['s'];
$page = http_get($site);
print $page;
?>


This script is obviously very simple and needs expansion before it's really useful. But, it could pretty easily be expanded to search and replace URL's from the form of URL to script_location?s=URL, print content-types, etc. The important part is that the basic functionality is very easy to implement.