Jump to content

displaying images using the readfile command


Jalz

Recommended Posts

Hi all,

 

Just wanted to know if you can point us in the right direction.

 

I have created a folder on the c drive outside my wwwroot folder called myImages and am trying to output the data on my webpage. The ImageURL field contains the pathname, so it would contain "c:\myImages\nameofimage.png"

 

I have the following code, and the webpage is just showing garbage, any ideas what I am doing wrong?

 

Many Thanks all

 

J

 

<?php 			
		$filePath = $MyDetails_row->getField('ImageURL'); 

		echo $filePath;
		  
		header('Content-type: image/png'); 
		header('Content-length' . filesize($filePath)); 
		  
		readfile($filePath); ?>

Link to comment
Share on other sites

Hi Guys,

 

Thanks for this, sorry the echo $filePath; was there as a mistake, just making sure it had the correct path.

 

Tried both of the code options and both interestingly give me the same 'garbage' briefly looking at it. I definately have png file stored in that location as I thought it was the header details. Any other ideas?

 

 

This is what I have tried so far

 

Many Thanks

$filePath = $MyDetails_row->getField('ImageURL'); 		  
header('Content-type: image/png'); 
header('Content-length' . filesize($filePath)); 	
echo stream_get_contents(fopen($filePath, "r"));

or

$filePath = $MyDetails_row->getField('ImageURL'); 		  
header('Content-type: image/png'); 
header('Content-length' . filesize($filePath)); 
echo file_get_contents($filePath); 

Link to comment
Share on other sites

Thanks de.monkeyz,

 

should have looked harder at the headers- had a feeling it was there. OK, got rid of the garbage but now I get the infamous red cross (which you get on sites with images missing). again checked filePath to make sure it has "c:\myImages\myimagename.png" in it, which it does. Any else Im doing which I shouldn't be?

 

J

Link to comment
Share on other sites

If view source is only showing that, the png image seems to be empty. That I THINK is just the binary code of the start of any png (I just tried the code with my own png and it showed that at the start). Since there should be A LOT more output than that

 

This is the type of output you'd have

2010-04-27_1735.png

Link to comment
Share on other sites

Hi Guys,

 

This is what the output is saying....

 

<HTML><HEAD>

<META content="text/html; charset=windows-1252" http-equiv=Content-Type></HEAD>

<BODY><IMG src="http://localhost/the_folder/testdisplayimage.php"></BODY></HTML>

 

I'll put the errors messages on and test with some other images; got to head out for a meeting now thank you so much for your helps guys - hoping to suss this out later.....

Link to comment
Share on other sites

perhaps it might be time to test the image itself.

 

1. temporarily put a copy of the png file in the same folder as your php script

2. make a simple php script

<?PHP
$file = "nameofimage.png";
?>
<IMG src="<?PHP echo $file;?>">
<?PHP
?>

 

if its a valid image file it should display.

 

If it does display, then is it possible that PHP cannot access the 'above root folder"?

 

(you also might create a simple txt file in the 'above root folder' and do another test where you create a simple php script to read the txt file) ie the old standby 'Hello, World'

 

just an old guy's musings

 

 

Link to comment
Share on other sites

Hello again,

 

I'm back and i've decided to change the imagetype to jpg for testing purposes to see if it behaves differerently. my new code is now

$filePath = $MyDetails_row->getField('ImageURL');		  
		header('Content-type: image/jpg'); 
		header('Content-length:' . filesize($filePath));
		echo file_get_contents($filePath); 

 

I've also turned errors on the page like PFMaBiSmAd suggested. In I.E 8 I do get garbarge like what you showed but no image. In FireFox I just get http://localhost/foldername/testdisplayimage.php displayed in my browser. When you did your test, were your images outside the webroot folder?

 

Thanks Jalz

Link to comment
Share on other sites

ok here goes,

this is from the jpeg version as the png dont even display this but works ok when the png is in the webroot folder

 

I'll only attach a page worth of garbage as im sure you dont want all of it?

 

Thanks all again

 

 

ÿØÿàJFIFHHÿá®ExifMM*bj(1r2Ž‡i¤Ð
ü€'
ü€'Adobe Photoshop CS3 Windows2010:04:23 13:02:43  Ö 	&(.xHHÿØÿàJFIFHHÿíAdobe_CMÿîAdobed€ÿÛ„			



ÿÀ+ "ÿÝ
ÿÄ?	

3!1AQa"q2‘¡±B#$RÁb34r‚ÑC%’Sðáñcs5¢²ƒ&D“TdE£t6ÒUâeò³„ÃÓuãóF'”¤…´•ÄÔäô¥µÅÕåõVfv†–¦¶ÆÖæö7GWgw‡—§·Ç×ç÷5!1AQaq"2‘¡±B#ÁRÑð3$bár‚’CScs4ñ%¢²ƒ&5ÂÒD“T£dEU6teâò³„ÃÓuãóF”¤…´•ÄÔäô¥µÅÕåõVfv†–¦¶ÆÖæö'7GWgw‡—§·ÇÿÚ?ÊoÕÞ°^­ €a¶>¦Œ±ß÷ÔFýZêÏqÚÊìv€·{xìàáù‹ªÆÇ7[E,k=[	cÙ$†ºÝ³ýJÖƒúF]uÙcv1¬a/s¶8éîq~áÿ~U‘Ô«pðÇBǺ¦=˜½Vú.o§m>×°þk‡æ¨0°·Ê~Œr~—µo}yé·¬fÌf¶×åc×{«dHÚÏJÛ!¤·gè4ãe.÷·ná-âîæv»û*hë|òù›aÍk¤KgXCÄnëعÁ¢u]ùüûSŒ†8¶±¡$4Èît•§Ð1.¯¨YŒôZí¯sijw¨k¨¿¥g»Õúýž¢=
¢.A>WIÍ¡þ¥”œÌbgsZCˆ˜-{gô^àªUÐ_‹Mw]‹Huµmõvmmý)eo}5»ôŸ¾»ŒÌ^›õzÜ‹Y™Ó
½”Uê6ÆÝc†Ìv6¼íù>Ýk¶Yú/ç=K=J×-Òq²nÇ·2îcì™
ª_sXÆï¯~ö;Òö;zhâÔŽŒ²kt~µ}Y£§ôÜ{1jÍõé±µ]n[Úí­õ¿#~8cŸüÆÍ–¬—Cœ×I‡Äêþêéþ¿dõ,z0:xõëé×T.smq±Û›S+ÈŸµµú5ÛUO}žû=[žû–Õ¾œü̯LZ1i6mȽà¸5°Øk)öî³wç»ù´<6VH:}'.ì‹šç;qnÖ´a­ãvÈ>ýîÜ»«®¹õúnªÂÚÛ\櫓¯e>›¿GOÐwæ³þ	s¹?Qs°rVæêA—:ç
ÖRïgÚéì¦ßOÕoæzÕÚ·c)¿Qr¬i»Ê1M-¶ßlÛ¸
þϵﻦÌûgØš`dA®‹âc›ÐÚùÇTeæåg‡ÐËžcCZ>—æ1›}Ÿ˜ÅRª®tÖÀ_k†Ö°N³ôyZtl¼‚Â×c¸9ÛM6XXö’}1»c}»Ÿüß»ÓWú%UfŠ3hs¡®9°÷?éz›v4ú;w{íÛìÿH¤7ÃñK³[¦õ“m®Ãsê£vŒ-iœË\í¯þ¯Ó]Fú›Óº¯KÕmyŽ’ÖÏL8ôÝTz›?—½7X¥9”1•Zþ“cñn·WcÖ—^ױͯ{vnº¬Š?Gú;>¥×HÌÍ ;Ë趻1ÃXÞXE·U½ÛÚëjvËm¯ù»í¥$Øg5oœöàe6’ïUÍÕ䈇ìh?ÊoÒZØfü7Ó_¨ëðì–šß´¸¬©çý£õ|
™.êö¸9ÙÕ´µÌØ7oôÚ^_ù¿¢]WHÃÊéÞ¥MÈÙM¦ÊØç—ÔøüëÙº¼zgþÿ]@Fš¤@îM:lµ´Øñé87G¸ßú
…®h‰]ÚÛ»Ûô”¨‘[}¤5¡®[mÔB#m€;¾–âHŸÞŸA2ÓOÿÐØeùms
9>¬$6Æ‚þÅ»OM•·é½¿A[}dvy²%ÓUm–þ{}˜¬ÿ³›XµÇÖ$¹Î/¬ŠÉçÝîm›ìPê
é9î©âÛN-¢‘¡#ÙgcÝùߺ©‰ 4~QR§ƒÅÏÊëŸY}{2/Úí}ï 6ºkþlƒký*kck¯ü%«wë¯ÕþƒÓ:^5˜[}ksÈ%ÌÉe–Q“鵕ÑO¿ô‹àíX_TrÛÒ:î.sîkqÜÈsÃE­q{-¨Ã·Væî]?׎°léýùÍê7é•}•–Vêz2ú›üåÖ}
œ®šÿOüã÷­
©¯Â8ŽöñظؖÛ.$À&8;{(.‹ê†ÙýG3
‡Vës±_fÌ’çT÷±Í5`õ=Žµïÿ·-ŠýŽÆk´5ퟎÕÐýWêé6ÝKÞÛ|6½©çOå¹·)Æ›07úÎAÉè2¼†MÌ·'}–<Ûpu"¼m¾óo§S,²ÖUé»Ñ³Óõë­?Õ|ºè§©â\FìÜ>Ïke¶ëcÿ™u>æ:ê]gÑú~‡¥þYu=3êýùY~f}™§dÒw;ôcô;%´Wÿj>õú7þ’Ï´.[Ö¿
§i>>”ÿ'`NœDNŸbé|Ö÷]S¡çt,7de:«q0™KâÐíïs^û}ORÇUëc?ÞÇú4ƒ¦°zhÆ¢¬<zìn-98ïê^ö nÛU[7V÷Ué×ûÿáU~§˜ü®Ôí,-f54`V]ùÏ~U™×Ÿëm¶¯ü…ͪý3©çÙÑ™ŒÇX[X, ÁsNæ>\ãí©þsr¦xŒ²\¸¢$îþ®2¯ù̸èKmuüßJ=Y®Äk®±·qM&’ÆäTMôîyýb·í¿Ù²¿F¶,«ðÀé½ËÆÚn~ÛŒO¥Hõ[‹¾ÂßS"Æú[ýŸ£V3l£/¥¬7}ŸpƳkE[žo©›?šôØÊýûóââú÷[~G]fV)sqñHƱÚFÇ}¢ë=¿ðÎÛ¿þ
Xå
ȸŒ@óFzÒ©U}/>ú1rÅÃÀ)̭›¶ÆYì67ôW}6ÿ!G*є̧½Óu¦ŒË(pÜk†O®Æ·gÒ±¯üÿJßÌY)×u<çîõ.ºÍÍ:û·ä¹jýVêdWWX`n'¼7!íÒšßéZvû÷WßÑ]`:­‰pÈ6èýuêÂìŒ,jìµØ­uÙÙÜðëZÚ»iÛ^=3»fïðŠ?Púë:U½A¶:¶å
=Lg[%¶;}˜²Ò×z—ûEŸñý"—SÅè½S¥Y×qÞê›[N5,x.psØÖdjïO'7w­³êõ¾•É2 Æš÷5´™²}ÆaÛ!21¯¾ôfeÃ~’c®IO^·+$âT]}zÁÆ7h]ú-ÁþŸé½7ú›Wm_YÆÃúµC¬u‡?©°‡ÜÿI£ôÖ×ù¿fôÜÖÓÿu~§é½Eä¸6º»Zö»c†¡Üí#ÜÉÚ½OêwÖŸÔÔlÈÄ;±ë'9¢ÏÔqÚÊÙŠïðûÏ«{?Â]“ÿm¾…“KŒ¿Wu2?dxxZ8Zo¥ÖWuM±€–µÀíx`ÓgzìýÏrßÇÉ£.¦ÝAý	–¾FÒ#Ô­áÏsWžg[XËcªo§KÈ5Ö$íiu—Šÿ;vÏjé¾­fX×e³kì§ÑìgÒ/ÏMü÷ÜÏ Ïß­E–È
¥Øæx¨›·ÿÑØkØZI2ÐÇö=«ë?YôÁéØÎsr/¥¿hy
ºÜL1Ýeíoç5Jé³Öª=O?¥ÿGwæþæÕÀ}cùÇ—¢)‰™þn¿æ÷{½?몘¸x½TÝËÅÁé߯“Ÿ^U½®pmåÇÙ¸†Ã™ïÚÍ›~“W_õÛ;£õ~™W£NV=ØC6€ú©·óžü{–Ïìz«’oÐtÄzµý/£ßùˆ÷úë­Åßÿ2}³?µ³ÕÙ¶vûþË¿ó¶Iõ¿Gý#Ðý2´xzUÓZH$D‘Ät~‘ÿóëců§]FÀßpk‡ýxÜKs«h.f¶°Ï-×Ýë±TgôÖñ_xQÿÍþvÏÜܬëédÿžcŽó‰ñ»ÑÕ«©÷ô±Ÿ½ØXÕ²»És½l—{ÓÛôÿà™éªÝUø·u\öbí¶mk
ck5ie©¿›^öûzcÒí>Œø~wç$ÍÞµñº=*ÿ›Û·ó¿{ß·ÿR¡;÷	•ñQ±ú;ÿÒ]¯	Ð|Ûþ“Ÿö«êmxÆçýÁŽºãé’é5ý?kX½‹êñé}êO~{Ûv[mȱÎüûŸúW·ÑöÖÖ3þ.•ãþ–ÉŽ*ø}ø/Rê_gÿ˜½#í_eÙö†ú´ýoKvË£Ñý›úoKý7ÚWô=_ø4ÃÃGÏZî¨ñq
ߣ¡×Ós:ŸA»=ƒ#¦f2ꨂëm4ú7µŽôÿ@ÿÑW[ÿ?Õõ?›÷¯9êõbŽ¥—V){h§!ì«|µá­qcØæŸøFþzï¿ÆTþ×è_Ol»ˆô§ÔÇúŸêï¿ü"ó«çí?J~Ñw1»é÷þWúDÜ_Îún¸GøÜLÙ?™UÅÄtþ¯òÿ˜ÑÈsCÚóíôçÌ™.çúʹÌÂô›~A»ÿꞟ/éÙýFqÏÒ?IW?Ì~›¿êX§•Û]í:ìÛºx¹‘[ufËIÛ¸l¶¦5öƒ«Ô£nåÎdšVg¢©ÖX*:’æ¯Tj?£Ùüìog?Ìsoó_þ·ª/Ÿ±[áëwŽdÿ5ùßñ¿˜£¯Q6vÛôQ
áÐúäoô¿ºªÜ [õ_¨ÙÑïǶêf.V-•¸VFíö»½¯-öúmbã‡þ¨ü‹¯³Šøüߣô~æßSÅ¥Ïêv=·áÖçmÄ<hHhK_5ÕýI³}¶z‡GQïùZÐ×7Ÿ¡½qcúf/<;Ž{.‹ê«¶Ý¾´úVDz{ãu_ÍïöìÿK»ßüâƒ?µ>š´¶H|ÁÿÙÿíÞPhotoshop 3.08BIM%8BIM/JÿÿHHÐ@dÀ°'llun×8BIMíHH8BIM&?€8BIM
x8BIM8BIMó	8BIM
8BIM'
8BIMõH/fflff/ff¡™š2Z5-8BIMøpÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿèÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿèÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿèÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿè8BIM8BIM8BIM08BIM-8BIM@@8BIM8BIMI	Ö
Untitled-1Ö	nullboundsObjcRct1Top longLeftlongBtomlong	RghtlongÖslicesVlLsObjcslicesliceIDlonggroupIDlongoriginenumESliceOrigin
autoGeneratedTypeenum
ESliceTypeImg boundsObjcRct1Top longLeftlongBtomlong	RghtlongÖurlTEXTnullTEXTMsgeTEXTaltTagTEXTcellTextIsHTMLboolcellTextTEXT	horzAlignenumESliceHorzAligndefault	vertAlignenumESliceVertAligndefaultbgColorTypeenumESliceBGColorTypeNone	topOutsetlong
leftOutsetlongbottomOutsetlongrightOutsetlong8BIM(?ð8BIM8BIM” +àP xÿØÿàJFIFHHÿíAdobe_CMÿîAdobed€ÿÛ„			



ÿÀ+ "ÿÝ
ÿÄ?	

3!1AQa"q2‘¡±B#$RÁb34r‚ÑC%’Sðáñcs5¢²ƒ&D“TdE£t6ÒUâeò³„ÃÓuãóF'”¤…´•ÄÔäô¥µÅÕåõVfv†–¦¶ÆÖæö7GWgw‡—§·Ç×ç÷5!1AQaq"2‘¡±B#ÁRÑð3$bár‚’CScs4ñ%¢²ƒ&5ÂÒD“T£dEU6teâò³„ÃÓuãóF”¤…´•ÄÔäô¥µÅÕåõVfv†–¦¶ÆÖæö'7GWgw‡—§·ÇÿÚ?ÊoÕÞ°^­ €a¶>¦Œ±ß÷ÔFýZêÏqÚÊìv€·{xìàáù‹ªÆÇ7[E,k=[	cÙ$†ºÝ³ýJÖƒúF]uÙcv1¬a/s¶8éîq~áÿ~U‘Ô«pðÇBǺ¦=˜½Vú.o§m>×°þk‡æ¨0°·Ê~Œr~—µo}yé·¬fÌf¶×åc×{«dHÚÏJÛ!¤·gè4ãe.÷·ná-âîæv»û*hë|òù›aÍk¤KgXCÄnëعÁ¢u]ùüûSŒ†8¶±¡$4Èît•§Ð1.¯¨YŒôZí¯sijw¨k¨¿¥g»Õúýž¢=
¢.A>WIÍ¡þ¥”œÌbgsZCˆ˜-{gô^àªUÐ_‹Mw]‹Huµmõvmmý)eo}5»ôŸ¾»ŒÌ^›õzÜ‹Y™Ó
½”Uê6ÆÝc†Ìv6¼íù>Ýk¶Yú/ç=K=J×-Òq²nÇ·2îcì™
ª_sXÆï¯~ö;Òö;zhâÔŽŒ²kt~µ}Y£§ôÜ{1jÍõé±µ]n[Úí­õ¿#~8cŸüÆÍ–¬—Cœ×I‡Äêþêéþ¿dõ,z0:xõëé×T.smq±Û›S+ÈŸµµú5ÛUO}žû=[žû–Õ¾œü̯LZ1i6mȽà¸5°Øk)öî³wç»ù´<6VH:}'.ì‹šç;qnÖ´a­ãvÈ>ýîÜ»«®¹õúnªÂÚÛ\櫓¯e>›¿GOÐwæ³þ	s¹?Qs°rVæêA—:ç
ÖRïgÚéì¦ßOÕoæzÕÚ·c)¿Qr¬i»Ê1M-¶ßlÛ¸
þϵﻦÌûgØš`dA®‹âc›ÐÚùÇTeæåg‡ÐËžcCZ>—æ1›}Ÿ˜ÅRª®tÖÀ_k†Ö°N³ôyZtl¼‚Â×c¸9ÛM6XXö’}1»c}»Ÿüß»ÓWú%UfŠ3hs¡®9°÷?éz›v4ú;w{íÛìÿH¤7ÃñK³[¦õ“m®Ãsê£vŒ-iœË\í¯þ¯Ó]Fú›Óº¯KÕmyŽ’ÖÏL8ôÝTz›?—½7X¥9”1•Zþ“cñn·WcÖ—^ױͯ{vnº¬Š?Gú;>¥×HÌÍ ;Ë趻1ÃXÞXE·U½ÛÚëjvËm¯ù»í¥$Øg5oœöàe6’ïUÍÕ䈇ìh?ÊoÒZØfü7Ó_¨ëðì–šß´¸¬©çý£õ|
™.êö¸9ÙÕ´µÌØ7oôÚ^_ù¿¢]WHÃÊéÞ¥MÈÙM¦ÊØç—ÔøüëÙº¼zgþÿ]@Fš¤@îM:lµ´Øñé87G¸ßú
…®h‰]ÚÛ»Ûô”¨‘[}¤5¡®[mÔB#m€;¾–âHŸÞŸA2ÓOÿÐØeùms
9>¬$6Æ‚þÅ»OM•·é½¿A[}dvy²%ÓUm–þ{}˜¬ÿ³›XµÇÖ$¹Î/¬ŠÉçÝîm›ìPê
é9î©âÛN-¢‘¡#ÙgcÝùߺ©‰ 4~QR§ƒÅÏÊëŸY}{2/Úí}ï 6ºkþlƒký*kck¯ü%«wë¯ÕþƒÓ:^5˜[}ksÈ%ÌÉe–Q“鵕ÑO¿ô‹àíX_TrÛÒ:î.sîkqÜÈsÃE­q{-¨Ã·Væî]?׎°léýùÍê7é•}•–Vêz2ú›üåÖ}
œ®šÿOüã÷­
©¯Â8ŽöñظؖÛ.$À&8;{(.‹ê†ÙýG3
‡Vës±_fÌ’çT÷±Í5`õ=Žµïÿ·-ŠýŽÆk´5ퟎÕÐýWêé6ÝKÞÛ|6½©çOå¹·)Æ›07úÎAÉè2¼†MÌ·'}–<Ûpu"¼m¾óo§S,²ÖUé»Ñ³Óõë­?Õ|ºè§©â\FìÜ>Ïke¶ëcÿ™u>æ:ê]gÑú~‡¥þYu=3êýùY~f}™§dÒw;ôcô;%´Wÿj>õú7þ’Ï´.[Ö¿
§i>>”ÿ'`NœDNŸbé|Ö÷]S¡çt,7de:«q0™KâÐíïs^û}ORÇUëc?ÞÇú4ƒ¦°zhÆ¢¬<zìn-98ïê^ö nÛU[7V÷Ué×ûÿáU~§˜ü®Ôí,-f54`V]ùÏ~U™×Ÿëm¶¯ü…ͪý3©çÙÑ™ŒÇX[X, ÁsNæ>\ãí©þsr¦xŒ²\¸¢$îþ®2¯ù̸èKmuüßJ=Y®Äk®±·qM&’ÆäTMôîyýb·í¿Ù²¿F¶,«ðÀé½ËÆÚn~ÛŒO¥Hõ[‹¾ÂßS"Æú[ýŸ£V3l£/¥¬7}ŸpƳkE[žo©›?šôØÊýûóââú÷[~G]fV)sqñHƱÚFÇ}¢ë=¿ðÎÛ¿þ
Xå
ȸŒ@óFzÒ©U}/>ú1rÅÃÀ)̭›¶ÆYì67ôW}6ÿ!G*є̧½Óu¦ŒË(pÜk†O®Æ·gÒ±¯üÿJßÌY)×u<çîõ.ºÍÍ:û·ä¹jýVêdWWX`n'¼7!íÒšßéZvû÷WßÑ]`:­‰pÈ6èýuêÂìŒ,jìµØ­uÙÙÜðëZÚ»iÛ^=3»fïðŠ?Púë:U½A¶:¶å
=Lg[%¶;}˜²Ò×z—ûEŸñý"—SÅè½S¥Y×qÞê›[N5,x.psØÖdjïO'7w­³êõ¾•É2 Æš÷5´™²}ÆaÛ!21¯¾ôfeÃ~’c®IO^·+$âT]}zÁÆ7h]ú-ÁþŸé½7ú›Wm_YÆÃúµC¬u‡?©°‡ÜÿI£ôÖ×ù¿fôÜÖÓÿu~§é½Eä¸6º»Zö»c†¡Üí#ÜÉÚ½OêwÖŸÔÔlÈÄ;±ë'9¢ÏÔqÚÊÙŠïðûÏ«{?Â]“ÿm¾…“KŒ¿Wu2?dxxZ8Zo¥ÖWuM±€–µÀíx`ÓgzìýÏrßÇÉ£.¦ÝAý	–¾FÒ#Ô­áÏsWžg[XËcªo§KÈ5Ö$íiu—Šÿ;vÏjé¾­fX×e³kì§ÑìgÒ/ÏMü÷ÜÏ Ïß­E–È
¥Øæx¨›·ÿÑØkØZI2ÐÇö=«ë?YôÁéØÎsr/¥¿hy

Link to comment
Share on other sites

Hi again,

 

Yes, its ultimately out of the webfolder due to security. I'll have to check the permissions of the folder and make sure IIS users have read permissions. Do you think they will need something else?

 

Jalz

Link to comment
Share on other sites

Is this correct: With the header() statements commented out, you get the contents posted in Reply #17 and with the header() statements in the code you get a broken red-x image? Does that exact same image file work when it is placed inside the document root folder?

 

What does a phpinfo(); statement show for the magic_quotes_runtime setting (I see a few \ in the data that could be escape characters)?

Link to comment
Share on other sites

Hi PFMaBiSmAd,

 

The magic_quotes_runtime setting is switched to off.

Copied the exact image into my webfolder and changed the filepath so it is 'ajkimage.png'. With the headers commented out, I get the gibberish, with them included in the code I get a red cross. This is in I.E 8. FireFox says the image in http://localhost/folder/testdisplayimage.php cannot be displayed as it contains errors.

 

I get the same results when I try a change the filePath to the image that is outside the webroot.

Link to comment
Share on other sites

This is my entire php file which I am using to test this feature. It may look a little strange, as it is connecting to a FileMaker database, but the connection etc all work; Just cant get the image to display

 

<?php 
ini_set("display_errors", "1");error_reporting(E_ALL);
require_once('Connections/dbConnect.php'); ?>
<?php

$MyDetails_find = $OO_Secure->newFindCommand('Members');
$MyDetails_find->AddFindCriterion('MemberID',$_SESSION['memberid']);

$MyDetails_result = $MyDetails_find->execute(); 

if(FileMaker::isError($MyDetails_result)) fmsTrapError($MyDetails_result,"error.php"); 

$MyDetails_row = current($MyDetails_result->getRecords());

// FMStudio v1.0 - do not remove comment, needed for DreamWeaver support ?>

<?php 	
		$filePath = $MyDetails_row->getField('ImageURL');	
		//$filePath = 'ajktest.png';	  
		header('Content-type: image/png'); 
		header('Content-length:' . filesize($filePath)); 	
		echo file_get_contents($filePath);

?>

Link to comment
Share on other sites

Exiting and entering php like that for no reason could be the reason, change it to this:

<?php 
ini_set("display_errors", "1");error_reporting(E_ALL);
require_once('Connections/dbConnect.php');

$MyDetails_find = $OO_Secure->newFindCommand('Members');
$MyDetails_find->AddFindCriterion('MemberID',$_SESSION['memberid']);

$MyDetails_result = $MyDetails_find->execute(); 

if(FileMaker::isError($MyDetails_result)) fmsTrapError($MyDetails_result,"error.php"); 

$MyDetails_row = current($MyDetails_result->getRecords());

// FMStudio v1.0 - do not remove comment, needed for DreamWeaver support

         $filePath = $MyDetails_row->getField('ImageURL');   
         //$filePath = 'ajktest.png';     
         header('Content-type: image/png'); 
         header('Content-length:' . filesize($filePath));    
         echo file_get_contents($filePath);

 

Notice I even removed the final ?> which is valid and prevents any accidental output after the php

       

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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