Jump to content

Archived

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

thedust2010

fopen() and retrieving a blob from a dynamic URL

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

Share this post


Link to post
Share on other sites
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!!

Share this post


Link to post
Share on other sites

×

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.