By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,376 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

PHP exec upsetting get_file_contents

P: 9
I'm running with PHP5 on WAMP & have come across a problem. I use the following php script to respond to an <image src="this.php?source=xxx">
Expand|Select|Wrap|Line Numbers
  1.  // get $source & $res 
  2.     $command = "convert -geometry $res $source gim29.gif";
  3.     exec($command);
  4.     if (file_exists("gim29.gif")) {
  5.         if($img     = @file_get_contents("gim29.gif")) {
  6.                                   header("Content-type: \"image/gif\"");
  7.                                   print $img;
  8.                                 }
  9.                 }
This fails - I do not get the image to my browser. Inspecting file gim29.gif shows it to be good - convert did the job. In fact - if I comment out the exec all works well! Also if I substitute the "convert...." with "ls -l" it still fails !!!
Dec 10 '07 #1
Share this Question
Share on Google+
2 Replies

P: 9
More info:
File getim.htm contains:
<image src="./getim.php">
File getim.php contains:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     $command="dir";
  3.     exec($command);
  4.     $img=file_get_contents("gim29.gif");
  5.     header("Content-type: \"image/gif\"");
  6.     print $img;
  7.     exit ();
  8. ?>
Silly test I know, but demonstartes the problem.
Call getim.htm in browser & PHP/Apache just hangs
Comment out the exec() & all's well

HELP please - I need to use exec() in my scripts
Dec 10 '07 #2

P: 9
Even more info.
Looks like Windows only

Tried the above little test on Linux Server & all's well

Trouble is - I need it to work on Windows
Dec 10 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.