Jump to content

Using get_file_contents() with a dynamic URL


thedust2010

Recommended Posts

I have a URL that when entered returns a file.  It's something like http://yourdomain.com/file.php?fileID=43433.  If I enter that URL I will get the image or document that I'm looking for.  No HTML at all.  Just the file.

Now, I'm trying to use the following line to capture that file in order to include it in a zip file using the following line:

[code]$fileContents = file_get_contents("http://yourdomain.com/file.php?fileID=43433")[/code]

It is returning true, but the file is always less than 4K.  It's not grabbing the contents of the file, even though it is returning true.  The thing is I HAD this working at one point, but now I don't know what is wrong... does anyone have any ideas on why this might be happening to me?  Or examples of how others have done this?
Link to comment
Share on other sites

Not 100% but have you tryed simply using

$fileContents = file("http://yourdomain.com/file.php?fileID=43433");

http://uk2.php.net/manual/en/function.file-get-contents.php
"Identical to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes."

Maby reaching a set max somehow?

Regards
Liam
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.