You are not logged in.
Hi All,
I am a first time poster but a long time user of Arch :)
I've setup a dev environment using Arch and I am learning PHP and trying to develop a webapp.
Currently I am having problems displaying images while playing around with some simple code - Getting the broken image icon.
Below is the code -
<?php
error_reporting(E_ALL);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_FILES['photo']) && is_uploaded_file($_FILES['photo']['tmp_name'])
&& $_FILES['photo']['error'] == UPLOAD_ERR_OK) {
if ($_FILES['photo']['type'] == 'image/jpeg') {
$tmp_img = $_FILES['photo']['tmp_name'];
$image = imagecreatefromjpeg($tmp_img);
header('Content-Type: image/jpeg');
imagejpeg($image, '', 90);
imagedestroy($image);
} else {
echo "Not a valid file!";
}
}
} else {
?>
<form action="test.php" method="post" enctype="multipart/form-data">
<label for="photo">User Photo:</label>
<input type="file" name="photo" />
<input type="submit" value="Upload a photo" />
</form>
<?php } ?>
When I do a print_r output of the $_FILES array I get the correct stuff:
Array ( [photo] => Array ( [name] => IMG_0304-pola.jpg [type] => image/jpeg [tmp_name] => /tmp/phpplz8js [error] => 0 [size] => 293851 ) )
Oh and here is my GD information:
gd
GD Support enabled
GD Version 2.0
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.3.12
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version unknown
PNG Support enabled
libPNG Version 1.4.0
WBMP Support enabled
I am wondering if I am missing anything (spastic typing hands) or permissions somewhere.
Thanks a lot everyone!
Offline
Hm. Works for me with PHP 5.3 and Firefox.
Have you tried to clear the cache?
(Firefox for example has cached the result on my computer)
Offline
Ah silly me. Forgot about that Thanks a lot for your help FOODy
Offline