lundi 20 avril 2015

Call image from Dump in real time php

I have three files first one is

First file code: Image.php

<?php
    header('Content-type: image/jpeg');

    $jpg_image = imagecreatefromjpeg('Desert.jpg');
    $white = imagecolorallocate($jpg_image, 73, 41, 236);
    $font_path = 'OpenSans-Italic.TTF';
    $text = $_GET['name'] ;
    imagettftext($jpg_image, 25, 0, 75, 50, $white, $font_path, $text);

    $image_url="dump/".rawurlencode(trim($text)).".jpg";

    imagejpeg($jpg_image,$image_url);
    readfile($image_url);
    imagedestroy($jpg_image);
?>

Second file code is :home.html

 <form action="result.php" method="get">
      <input type="text" name="name" id="name">
      <input type="button" name="submit" id="submit">
 </form>

Third file code is:result.php

<body>
    <img src="How to Get recently created image from dump folder"/>
</body>

As I have shown you I have three file one is home page and other two are of php I have added some php script on the home.html which redirects me to the result.php page. The function of image.php is to make a picture with some text on it which we will get from the user through input tag and as you know I have dump that image in an dump folder on my website. As we all know that we cannot write html in the image.php because it containsheader('content-type: image/jpeg'); so i have created a new file name result.php which will show the image which is named as what the user has inputed in the input tag and now i want to show it in the result.php and i dont know what user has given the name of image it is stored in dump folder of my website so how to get that dump image from the website and also check weather my coding is correct.

Aucun commentaire:

Enregistrer un commentaire