Jump to content

works on local , no response on remote


arash

Recommended Posts

i wrote code bellow , it works on local [tested by easy php] , but there is just no respone on remote  , like : http://yahooavatarload.sourceforge.net/?yid=darkeliden

 

code :

<?php

if (isset($_GET['yid'])) {
$id=$_GET['yid'];
$fn="http://img.msg.yahoo.com/avatar.php?yids=$id&format=png&width=120&height=120";
$handle = fopen("$fn", "r");
$contents = stream_get_contents($handle);
$fp = fopen('avats/'.$id.'.png', 'w');
fwrite($fp, $contents);
fclose($fp);


// load the image from the file specified:
$img="avats\\".$id.".png";
$im = imagecreatefrompng("$img");
// if there's an error, stop processing the page:
if(!$im)
{
die("");
}

// define some colours to use with the image
$yellow = imagecolorallocate($im, 255, 255, 0);
$black = imagecolorallocate($im, 0, 0, 0);

// get the width and the height of the image
$width = imagesx($im);
$height = imagesy($im);

// draw a black rectangle across the bottom, say, 20 pixels of the image:
imagefilledrectangle($im, 0, ($height-15) , $width, $height, $black);

// now we want to write in the centre of the rectangle:
$font = 3; // store the int ID of the system font we're using in $font
$text = "Y A L - NG"; // store the text we're going to write in $text
// calculate the left position of the text:
$leftTextPos = ( $width - imagefontwidth($font)*strlen($text) )/2;
// finally, write the string:
imagestring($im, $font, $leftTextPos, $height-13, $text, $yellow);

// output the image
// tell the browser what we're sending it
Header('Content-type: image/png');
// output the image as a png
imagepng($im);

// tidy up
imagedestroy($im);



}else{
echo "NO ID ENTERED";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/169829-works-on-local-no-response-on-remote/
Share on other sites

Instead do a file_put_contents() and wrap it to check and see if it returns false like so:

<?php
if(file_put_contents('avats/'.$id.'.png',$contents)===FALSE ) {
  echo 'You are encountering a problem writing to the disk on this server!';
  exit;
}

This will be a definitive answer if it is a write issue, if not then let me know and we will do some more trouble shooting.

Archived

This topic is now archived and is closed to further replies.

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