Link to home
Start Free TrialLog in
Avatar of lvmllc
lvmllcFlag for United States of America

asked on

SimpleImage PHP stopped working on Windows 2008 r2

I have been using simple fine for the last few years and have found that in some point in the last 3 months it stopped working for me.

doing a test with the following code produces no image on the screen - instead I get the text below the code. I am using the same practice image I usually use (as well as others) and get similar gibberish. I have tried this with both PHP 5.2.17 and 5.4.14 - same result.

<?php 
error_reporting(E_ALL);

if( isset($_POST['submit']) ) {   
	include('SimpleImage.php'); 
	$image = new SimpleImage(); 
	$image->load($_FILES['uploaded_image']['tmp_name']); 
	$image->resizeToWidth(150); $image->output();
	
} else {   
?>
The form:<br>
<form action="uploaderTest.php" method="post" enctype="multipart/form-data">
    <input type="file" name="uploaded_image" />
    <input type="submit" name="submit" value="Upload" />
</form>

<?php 
} 
?>

Open in new window




The screen output:
ÿØÿàJFIFÿþ>CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), default quality ÿÛC          $.' ",#(7),01444'9=82<.342ÿÛC         2!!22222222222222222222222222222222222222222222222222ÿÀp–"ÿÄ        ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚       %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ        ÿĵw!1AQaq"2B‘¡±Á      #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?öÅBqŽ+@XÈG8¦ÿf¿¨¬“(Ï|ªr¦sŠØk      Gj«%³÷y¦˜XÈhð2jŒu­'‰•WOɪ×IåÆI¨SBú2ÊJ•»;œÕm€ö­‹s¸“Pù Ñ2JÂ:vÜ œÇƒÅ”\ ø£¥Ûύ”\JÓ«3M)H Ä*fZ(ô¥¤¥¨(J¥v˜É­7P»’ÊkgHÚU‘¼¶G'=úU¹“|dVr×äRV0˜rx¨Ú<öâ«kÚ’èóiÏ*±†âè[»/Dܧ }·`~5¨bÈæ¦ãhÏh¸éU%v«r]F/žÏpˆ„ zŒü꼧É5IŠÅ      e ߟJ¡u déZR õZ[`èpqøÓ¸¬só6rqUðkBhâóªlW­j™vlКGÍJ#\b”§µL@©Œi\Jâ£j‘‰¨Xšk )“ÞŠ`}Eyύþ(éÚ‘ky¢ßéúŒí0ßs«Lç#œ~UÆ¿í}%”¾^ƒSýÛ›‚À]»yIv=¿íiS"y¾P&FìdŒãÒ§a¹H¯Œ5µ×Æ»ý¡)ÔCîóIý1Ó±Óô/ƒ>(è¾$Ó¯®­ôýB5tSÈ[ý¤'¨>GëI« ±½©iñÜÜZÅ2,¨d'k.F@Èý@«rDUqŽj¥Æ½£É{dcÕ,œol•¸Cü'Þ§]_N¼2 {ëiLm±öJ§ë\ÒÐÑ;˜ÓYyšÙ¹ c€&}U˜’?5ð¢xÖ(ÚI]R5fc€©5Áx¯â£øgÅ׺öds¢,jÍÆF7gÿý+Í|_ãýWÄò4RL!µ‹xN}¼}ÏáŠÒ1“hôÛ/ˆÚ5ÿ‰äÑám±Ÿ–¦?,Ü{{õÓ¼R¼{ùk89w¯^ðgÄ¥“K{-eØÜÛDZ9{̪3ŽˆÏëÖÜm±)÷;¹¡U®+*á      'SGñžâ9åŠÍ.£MìdP\v&¡ÔµpÇSL/ô¤;“’Y8ä.rj6“jf•XmÆjùŽ= +ŽQ¶¤Î¥1¹Î}©œS Ý·=†)Ì2>ðô¦IR©ÿëÔŒ¬sQ•ö5{Ëù䟟ÿ^ž¶›°[ÊГ@eO]´¢Êî>ß]¦¶E­š È彑OøÔR$â+i>¬ôÄe³¸Éüª2}«PÙ«òaûùN[.ÞKÿ]øR)»«€GË×ޝ¸tÇë[?Ùð¹S°~g'ù š+£bH³þÆ{ŸZd˜‹3{P«æ66’qÚº1¤`PþTðBð þ&€9ãjäpŸ¥GöYÁ Âÿ÷É®¤n£,þÿ€ ²Ïÿ<%ÿ¾M'Ù®?ç„Ÿ÷Á®ƒkÉ54qBÃæçÐœP5ök‘Ö'QŠr¤ áúçÔUûû;攘·y}‚¶k1íî²ÐÈ©ï@8Áù<Š)ZK"âKyGN1EYþА}èã?QDwÈ>Wˆu' úóU÷))ÏáL xÜ2+ŒÑ[«W dúð©Ä       Ìn¬=ŽkÈaÅ"³#¤©Çj.#XÛ‘ë@…‡z¯g¨7œ#³»€Ät5§¾2ÛIÃzb‹ŽÅSúÓqÞ¯yAº>? kÛžäQp±DîîM&O÷\6çÅFT/ÄA½‡ñ_5ýXÒ·µ0³ “ÍzQ3Tš““@üöõ£íÞ#òOšCÅZicläsìqP¢l¤Óo4â¢É 6(ð˜÷–Oû¼Ñ@O*Iæ7\þ5´aŽß,èBúP•òŸ»öÆjFdïÏJ7±ÿÙ      ÆLÄØOþ½=t%8-+ƒô˜Œ<œsŠÖ ½ŒW’\pÙç?äÕ•Ñ-×ï<‡ñáK䥽£ªýÝØúÐ ŽPnVϸ欉NÞâ«A'ɃŽ:bž\R!}à j7By‘OYžÇð¦VVô¨Êš¶ã<’@Ûêiˆ®ÀÓpjbÊ;S Ð ‹Þ“žâ¥Þ=)…ý¨0Ojµ!v¤ÞÞ´&ÓEG¹z(ÿÙ
SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lvmllc

ASKER

Changed PHP to include header as below below but still get an error.  The SimpleImage.PHP file is the same as I used 6 months ago.  The errors I see in the PHP log are as follows. It seems as if it is not passing the loaded image to simpleImage.php.


[14-[14-Oct-2013 12:26:07 America/Chicago] PHP Warning:  getimagesize(picture.jpg): failed to open stream: No such file or directory in C:\webSites\phpTest\SimpleImage.php on line 28
[14-Oct-2013 12:26:07 America/Chicago] PHP Warning:  imagesx() expects parameter 1 to be resource, null given in C:\webSites\phpTest\SimpleImage.php on line 60
[14-Oct-2013 12:26:07 America/Chicago] PHP Warning:  Division by zero in C:\webSites\phpTest\SimpleImage.php on line 71
[14-Oct-2013 12:26:07 America/Chicago] PHP Warning:  imagesy() expects parameter 1 to be resource, null given in C:\webSites\phpTest\SimpleImage.php on line 63
[14-Oct-2013 12:26:07 America/Chicago] PHP Warning:  imagecreatetruecolor(): Invalid image dimensions in C:\webSites\phpTest\SimpleImage.php on line 82
[14-Oct-2013 12:26:07 America/Chicago] PHP Warning:  imagesx() expects parameter 1 to be resource, null given in C:\webSites\phpTest\SimpleImage.php on line 60
[14-Oct-2013 12:26:07 America/Chicago] PHP Warning:  imagesy() expects parameter 1 to be resource, null given in C:\webSites\phpTest\SimpleImage.php on line 63
[14-Oct-2013 12:26:07 America/Chicago] PHP Warning:  imagecopyresampled() expects parameter 1 to be resource, boolean given in C:\webSites\phpTest\SimpleImage.php on line 83
[14-Oct-2013 12:26:07 America/Chicago] PHP Warning:  imagejpeg() expects parameter 1 to be resource, boolean given in C:\webSites\phpTest\SimpleImage.php on line 52




header('Content-Type: image/jpeg'); include('SimpleImage.php'); $image = new SimpleImage(); $image->load('picture.jpg'); $image->resizeToWidth(150); $image->output(); - See more at: http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/#sthash.w5GaMb3C.dpuf

Open in new window

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The code should Always have had the 'header' line, that's been a requirement for about 20 years.  Adding that alone should have caused the output to be sent as an image even if it isn't the right one.
Dave, the headers are set within the simpleimage class
Gary, not according to the SimpleImage doc page I posted that matches the rest of his code.  http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/   Note that there is more than one application named SimpleImage.
mmmm I was looking at this one
https://gist.github.com/miguelxt/908143
Avatar of lvmllc

ASKER

I have confirmed that the file is being written to the windows/temp dir.
Interesting, but the path was not listed in the .ini setting viewer. so went to the .ini itself and entered a different path and it said I had an error so I told it to default back. Now it does show up in the setting viewer.

So with that solved I tried it again and checked the dir where SimpleImage should place the thumbnail and the uploaded image. That dir somehow defaulted to read only. I set it to read write and it works again.  So my question now is there a way I can make it so only the script can writ to the folder and not anyone who goes to that URL?



Also, I noticed that when I added the header stuff that I mistakenly also added
$image->load('picture.jpg');
so changed it back to
$image->load($_FILES['uploaded_image']['tmp_name']);
No, it would need to run under the IUSR account, you cannot restrict access by file
Gary, the version in your link says it's a modified version and it does include the 'header' lines.  And the version in my link which appears to be the 'original' does not have the 'header' lines.  Wonder which version the asker is using?
Avatar of lvmllc

ASKER

The date on it was 8/11/2006  - so I know it is old.
I do know there are alternative versions.  Which are you looking at?
My link http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/ appears to be the original plus one update.  Gary's link https://gist.github.com/miguelxt/908143 is a newer version.