サイズを変更した後、画像が表示されません。
require('connect.php');
if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) {
// Temporary file name stored on the server
$tmpName = $_FILES['image']['tmp_name'];
$imagename = $_FILES["image"]["name"];
// Get new dimensions
list($width, $height) = getimagesize($tmpName);
echo "orginal width".$width."<br/>";
echo "orginal height".$height."<br/>";
$new_width= $width * 0.5;
$new_height = $height * 0.5;
echo "new width".$new_width."<br/>";
echo "new height".$new_height."<br/>"; //Its working fine till here.
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($tmpName);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
echo "My image"."<br>";
echo '<img src="data:image/png|image/jpeg|image/gif;base64,' . base64_encode( $image_p ) . '" style="max-width:400px; max-height:300px;"/>';
/* This line is not able to display the image.
Also tried imagejpeg($image_p, null, 100);. Not working , but anyway i need to
display image alongwith other content so i have used echo. Not sure which
variable i should work with to display the image and how do i do it.*/
}