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条)

报告相同问题?

悬赏问题

  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题