こんにちは、phpの初心者なので、私はそれについて多くの知識を持っていません。フォームメソッドを使用して画像にテキストを追加しようとしていますが、機能しません。コードは次のとおりです。
form-add-text.phpで
<form id="action-meme" action="mysite.com/image-process.php/">
<input name="cp" id="inputcpname" type="text" >
<input type="submit" >
</form>
これがimage-process.phpのコードです
<?php
//Set the Content Type
header('Content-type: image/jpeg');
// Create Image From Existing File
$jpg_image = imagecreatefromjpeg('http://i.imgur.com/xxxYpW.jpg');
// Allocate A Color For The Text
$white = imagecolorallocate($jpg_image, 255, 255, 255);
// Set Path to Font File
$font_path = 'http://fonts.googleapis.com/css?family=Gabriela';
// Set Text to Be Printed On Image
$text = $_POST["cp"];
// Print Text On Image
imagettftext($jpg_image, 25, 0, 75, 300, $white, $font_path, $text);
// Send Image to Browser
imagejpeg($jpg_image);
// Clear Memory
imagedestroy($jpg_image);
?>
ただし、「$ _ POST ["cp"]」をテキストに置き換えると、うまく機能します
自分の仕事がわからない