gloradin
05-06-2008, 04:07 PM
Hello,
I try to take url screenshots in php, and I try a script from php site with the fuction imagecreatefromjpeg, like this one:
<?
Header( "Content-Type: image/jpeg");
function LoadJPEG ($imgURL) {
##-- Get Image file from Port 80 --##
$fp = fopen($imgURL, "r");
$imageFile = fread ($fp, 3000000);
fclose($fp);
##-- Create a temporary file on disk --##
$tmpfname = tempnam ("/temp", "IMG");
##-- Put image data into the temp file --##
$fp = fopen($tmpfname, "w");
fwrite($fp, $imageFile);
fclose($fp);
##-- Load Image from Disk with GD library --##
$im = imagecreatefromjpeg ($tmpfname);
##-- Delete Temporary File --##
unlink($tmpfname);
##-- Check for errors --##
if (!$im) {
print "Could not create JPEG image $imgURL";
}
return $im;
}
$imageData = LoadJPEG("http://www.google.com");
imagejpeg($imageData, '', 100);
?>
But when I execute the script not appear any image contain the url screenshot.
If I execute the script in the script page (imagem_url.php) appear this phrase:"http://fotos.gloradin.com/experiencia/2/imagem_url.php".
If I call the image in other page don't appear anything, just a blank page.
I think I have to change something in the php.ini for authorize the image url capture, but I don't know what I have to change.
If the reason not is php.ini, what kind of problem my script have?
The best regards,
gloradin
I try to take url screenshots in php, and I try a script from php site with the fuction imagecreatefromjpeg, like this one:
<?
Header( "Content-Type: image/jpeg");
function LoadJPEG ($imgURL) {
##-- Get Image file from Port 80 --##
$fp = fopen($imgURL, "r");
$imageFile = fread ($fp, 3000000);
fclose($fp);
##-- Create a temporary file on disk --##
$tmpfname = tempnam ("/temp", "IMG");
##-- Put image data into the temp file --##
$fp = fopen($tmpfname, "w");
fwrite($fp, $imageFile);
fclose($fp);
##-- Load Image from Disk with GD library --##
$im = imagecreatefromjpeg ($tmpfname);
##-- Delete Temporary File --##
unlink($tmpfname);
##-- Check for errors --##
if (!$im) {
print "Could not create JPEG image $imgURL";
}
return $im;
}
$imageData = LoadJPEG("http://www.google.com");
imagejpeg($imageData, '', 100);
?>
But when I execute the script not appear any image contain the url screenshot.
If I execute the script in the script page (imagem_url.php) appear this phrase:"http://fotos.gloradin.com/experiencia/2/imagem_url.php".
If I call the image in other page don't appear anything, just a blank page.
I think I have to change something in the php.ini for authorize the image url capture, but I don't know what I have to change.
If the reason not is php.ini, what kind of problem my script have?
The best regards,
gloradin