![]() |
PHP+Apache: Problem trying to display BLOB field pictures
I've been stuck for someday trying to solve this problem. Still I doesn't find the clue.
I'm writing a simple blog with PHP and mysql. I'm uploading images files through form and storing them in a BLOB field: This is the main fragment, I'm using PDO extension. Code:
if ( $_FILES["archivo"]["error"] === 0 && $_FILES["archivo"]["size"] > 10 && $_FILES["archivo"]["size"] < 900000 && strpos($_FILES["archivo"]["type"], "image") !== false )Code:
mysql> describe sblog_post_pics;Code for storing the image seems to work ok. Put I can't get image shown. The code I used for this is the following: displaypic.php Code:
<?phpCode:
<?phpI was wondering if could be an specific apache issue... Something extra needed to be sent within http header? I don't know... Any suggestion will be very appreciated. I'm using Debian (Lenny), PHP 5.3 and Apache 2 (apache2 - 2.2.9-10+lenny8 ). Regards, Matías |
Hi
What is "/tmp/testimg.png" and "/tmp/displaypic.log"? It should be a PNG file and the MIME type. Edit, also: PHP Code:
PHP Code:
|
Guttorm,
Thanks for your reply. Really, I tried with and without addslashes function with the same result... Both files testimg.png and displaypic.log are just for testing porpouses, testimg.png is just a file written with the image data from the blob field, just to check if the data stored is ok. And that file seems to be ok, image is good. |
Hmm. Did you empty the browser cache? What is the output of this command:
wget --server-response http/localhost/displaypic.php?imgid=35 |
Guttorm,
Thanks! At job, I swithed my application to work storing pics in filesystem just for not to delay development. But at home I left my old version, tonight I'll try the wget test you passed me, and I'll let you know. I had made some tests with wget, but I didn't include --server-response that's interesting. |
Guttorm,
Well, this is the result of: wget --server-response http://localhost/.../displaypic.php?imgid=5 Code:
Petición HTTP enviada, esperando respuesta... If I do file command to the data saved by wget I get: Code:
matias@retux:~$ file displaypic.php\?imgid\=5 I've just found that downloaded file through wget is 1 byte bigger than the original image. I compared both files with: od -t x1 and in the beggining of downloaded file (the one using Blob) appears 0x0a as first character. Is it a LF character? Really, that could be the reason, but still I don't find from where that character could come. |
| All times are GMT -5. The time now is 10:52 AM. |