Jump to content

fopen() and retrieving a blob from a dynamic URL


thedust2010

Recommended Posts

I have a PHP script that accepts various paramters and outputs an image.  It works fine inside of an image tag but I can't use it with fopen() to attach to an email.  For example this HTML will display the custom image just fine:

[code]
<img src="http://www.mydomain.com/file.php?fileID=45598&constrain=550" />
[/code]

BUT using fopen() to attain the image as a blob is just not working:

[code]
$fileBlob = fread(fopen("http://www.mydomain.com/file.php?fileID=45598&constrain=550", "r"), $Row_File["fileSize"]);
[/code]

Any ideas on how this can be handled?  I do have allow_url_fopen set to true, so I'm not sure what the problem is...
I finally got this figured out.  I was having problems because I didn't realize when you make a request with fopen() or get_file_contents() it makes that request as an entirely new user with no saved session data.  Since that user is not logged in, it was refusing to serve up the file.  The way around this was to generate a random key, associate it with the file in the DB and then submit that key for validation at /file.php.  The temporary key is then deleted and everyone is happy.  Thanks for your help!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.