drgm51600 2013-03-26 10:29
浏览 40
已采纳

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

Hello am a newbie in php, so i dont have much knowledge about that. I am trying to add text over image with form method but that doesnt works Here are the codes

In 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>

Here is the code in 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);
?>

BUt if i replace "$_POST["cp"]" with some text it works well

I am unable to figure out my work

  • 写回答

2条回答 默认 最新

  • doushi5752 2013-03-26 10:32
    关注

    Try adding method to the form

     <form id="action-meme" action="mysite.com/image-process.php/" method="post">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效