在图像上添加文本时出现php错误

在图像上添加文本时出现php错误,php,image,wordpress,Php,Image,Wordpress,你好,我是php的新手, 所以我对此不太了解。 我正在尝试使用表单方法在图像上添加文本,但这不起作用 这是密码 格式为-add-text.php <form id="action-meme" action="mysite.com/image-process.php/"> <input name="cp" id="inputcpname" type="text" > <input type="submit" > </form> 下面是ima

你好,我是php的新手, 所以我对此不太了解。 我正在尝试使用表单方法在图像上添加文本,但这不起作用 这是密码

格式为-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);
?>

但是,如果我用一些文本替换“$\u POST[“cp”]”,效果会很好


我无法理解我的工作

请尝试向表单中添加方法

 <form id="action-meme" action="mysite.com/image-process.php/" method="post">

尝试向表单中添加方法

 <form id="action-meme" action="mysite.com/image-process.php/" method="post">

在表单中添加method=“post”

 <form id="action-meme" action="mysite.com/image-process.php/" method="post" >

<input name="cp" id="inputcpname" type="text" >
<input type="submit" >
 </form>

在表单中添加method=“post”

 <form id="action-meme" action="mysite.com/image-process.php/" method="post" >

<input name="cp" id="inputcpname" type="text" >
<input type="submit" >
 </form>