Jump to content

Getting a remote file


blackcat1313

Recommended Posts

I would like to get a remote file using HTTP and put its contents in a local page.  The function readfile() would do this very nicely, except you have to have allow_url_fopen set On.  My understanding is that this creates a security hole and many hosts have it disabled.  There are other functions too, like file_get_contents(), but they are all going to need allow_url_fopen in order to work.

 

Is this really a security problem?

 

If so, how can I get the file?

 

Thanks!

 

  Bill Osberg 

Link to comment
Share on other sites

Thanks Scott, I will investigate using cURL.  First thing is to see if my web host has it installed.

 

Hi Rohan, doing it this way is going to need allow_url_fopen set on.  As would include, fopen, and any of the other file manipulation functions.

 

I think I may be able to get it using FTP, copy it locally, then use include to read it in.  So I've got a couple of things to try.  Thanks.

 

    Bill

Link to comment
Share on other sites

Hi cooldude, thanks but the PHP manual says that file_get_contents needs allow_url_fopen set On to use a URL as the file name.  That's what I'm trying to avoid...

 

"You can use a URL as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename and List of Supported Protocols/Wrappers for a list of supported URL protocols."

 

 

Link to comment
Share on other sites

Most if not all hosts have to have them enabled in order to allow users to work with their own files.

 

So,

 

file_get_contents(http://www.phpfreaks.com/index.php);

 

should just show the page the same as any user sees it on the server.

 

You may need to think of hotlinking though, most sites disable that themselves.

 

I do not really know of any of the hosts I have used in the past to have disabled $FILES operations, users however can restrict it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.