thedust2010 Posted September 18, 2006 Share Posted September 18, 2006 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... Link to comment https://forums.phpfreaks.com/topic/21200-fopen-and-retrieving-a-blob-from-a-dynamic-url/ Share on other sites More sharing options...
ronverdonk Posted September 18, 2006 Share Posted September 18, 2006 Have you tried the 'file_get_contents' function?Ronald 8) Link to comment https://forums.phpfreaks.com/topic/21200-fopen-and-retrieving-a-blob-from-a-dynamic-url/#findComment-94301 Share on other sites More sharing options...
thedust2010 Posted September 20, 2006 Author Share Posted September 20, 2006 file_get_contents() does not work either... same result. The image is a 4 KB empty image file. :( Any other ideas? Link to comment https://forums.phpfreaks.com/topic/21200-fopen-and-retrieving-a-blob-from-a-dynamic-url/#findComment-95375 Share on other sites More sharing options...
thedust2010 Posted September 20, 2006 Author Share Posted September 20, 2006 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!! Link to comment https://forums.phpfreaks.com/topic/21200-fopen-and-retrieving-a-blob-from-a-dynamic-url/#findComment-95568 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.