简体   繁体   中英

space does not work in input tag with php

I'm using the following code in my php file.

<?php 
    $text = $_GET['name'];
    $image_url="dump/".rawurlencode(trim($text)).".jpg";
    $text= $_GET['name'];



        $jpg_image = imagecreatefromjpeg('image.jpg');
        $blue = imagecolorallocate($jpg_image, 59, 89, 152);

        $font_path = 'OpenSans-Italic.TTF';
        imagettftext($jpg_image, 22, 0, 278,37, $blue, $font_path, $text);


        imagejpeg($jpg_image,$image_url);
        imagedestroy($jpg_image);


    ?>

In this code I'm getting text from the input tag from my html file $_GET['name']; and I'm getting the image from the dump because I want it like that only.This ode is perfectly working but when I put "space" in the input tag it does not show me any image for eg:- name surname the space between name and surname when I'm giving space between any word it does't show me any result it is working fine without space hope you find solution.

Leave all the things just see what I have done I have tested it it is working well.

<?php 
$text = $_GET['name'];
$image_url="dump/".urlencode(trim($text)).".jpg";
$text= $_GET['name'];



    $jpg_image = imagecreatefromjpeg('image.jpg');
    $blue = imagecolorallocate($jpg_image, 59, 89, 152);

    $font_path = 'OpenSans-Italic.TTF';
    imagettftext($jpg_image, 22, 0, 278,37, $blue, $font_path, $text);


    imagejpeg($jpg_image,$image_url);
    imagedestroy($jpg_image);


?>

just removed the raw from $image_url="dump/".rawurlencode(trim($text)).".jpg"; and made it $image_url="dump/".urlencode(trim($text)).".jpg";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM