Forum Moderators: coopster

Message Too Old, No Replies

Email Attachments from MySQL

can read/write images to database, but can't attach them...

         

omicronpersei

4:08 pm on Mar 26, 2009 (gmt 0)

10+ Year Member



Current Situation:

I am successfully storing images to MySQL, and succesfully retrieving them for display on a page in the following format:

<img width="106" height="160" border="0" src="imageserver.php?image_id=44">

where imageserver.php echos the appropriate header and data for the image:
...
$result = $db->queryRaw($sql) ;
header("Content-type: $type");
echo mysql_result($result, 0);
...

Problem:

I would like to attach these images to an email. I have successfully attached standard files (in the form 'image_44.jpg'), but when I use 'imageserver.php?image_id=44', I get the following types of errors:

Warning: filetype() [function.filetype]: Lstat failed for [example...]

Warning: filesize() [function.filesize]: stat failed for [example...]

Warning: fread() [function.fread]: Length parameter must be greater than 0 in...

An example of the code that fails is:

$fileatttype = filetype($fileatt);

which works fine when it's a regular file... is there an extra step I'm missing to make data pulled from a database readable as a regular file?

gettopreacherman

4:17 pm on Mar 26, 2009 (gmt 0)

10+ Year Member



Off the cuff I would think that it's issue with the file not having rendered yet when you call it, so it attaches as a php file with no information in it. perhaps changing the file to a class and implementing it would make it render in memory and not return an empty file.