Forum Moderators: coopster
I'm a real beginner when it comes to PHP, so please bare with me.
I'm using a Java Applet to display an image:
<applet code="PoolMenu" width="272" height="432" align="top">
<param name="url" value="getimage.php">
My getimage.php file looks like:
<?php
header('Content-Type: image/jpeg');
readfile($image_name.jpg); //Path to image
?>
But the image is not displaying.
What is it that I am doing wrong in the "value" section of the applet?
I basically want to hide the URL of the image with PHP in the applet.
Any help or other ideas would be appreciated
Cheers!
header('Content-Type: image/jpeg');
Has be outputting a jpeg, readfile doesn't return a jpeg, it will probably be returning a jumbled string that is your jpeg, you should be using the GD library and the imageJPEG function. Its slightly detailed, I'd recommend searching for "php imageJPEG" and reading up on that, and possibly skimming the GD section of the PHP Manual.
Try pasting this into your script, that should get you started. instead of filling it with color though, you'd want to load a jpg from a file.
<?
Header ("Content-type: image/png");
$image = imagecreate(100, 100);
$black = imageColorAllocate($image, 0, 0, 0); // allocate color black
$blue = ImageColorAllocate ($im, 0, 0, 255);
// imagefill is optional since the image will automatically be created with the first
// color allocated: black. The fill covers up the black and makes the image blue.
// imageFill($image, 0, 0, 50, 50, $blue); // use it for drawing
ImagePng ($image);
// destroy the image to free memory
ImageDestroy ($image);
?>
Welcome to WebmasterWorld, Kyle2911.
I think your issue may actually lie in this line of your php script:
readfile($image_name.jpg); //Path to image
Are you certain that is what you want there? It seems perhaps you want something along the lines of
readfile("$image_name".'.jpg'); //Path to image You could always build a variable first and then dump it to your browser to see if it is indeed the path to the image, exactly as you expect it to be.