提交页面源码:
<form action="img.php" method="post">
<textarea name="word" onpropertychange="this.style.height=this.scrollHeight+'px';" oninput="this.style.height=this.scrollHeight+'px';" style="border:0px;overflow:visible;width:550px;font-size:12px;background-color:#f6f8f9;margin-left:10px; border:solid 1px #E2E2E2;padding:10px 10px;">
想实现Textarea自动适用高度且无滚动条,以下代码可以在IE下正常工作,在FF下基本功能也正常, \r\n
但是在FF下有个小问题:高度可自动增长,但是不能减小,请指教:
代码说明:onpropertychange:IE支持; oninput:FireFox支持;为了兼容IE和FF,所以加上了这个两个;
</textarea><input type="hidden" name="height" value="500" />
<input type="hidden" name="width" value="550" />
<input type="submit" name="提交" value="提交" />
</form>生成图片的源码:<?php
$img = imagecreatetruecolor($POST['height'],$POST['width']); //创建真彩图像资源
$color = imagecolorAllocate($img,255,255,255); //分配一个灰色
imagefill($img,0,0,$color); // 从左上角开始填充灰色
header('content-type:image/jpeg'); //jpg格式
// Add some shadow to the text
$text=$POST['word'];
echo $text;
$text = iconv('gb2312','utf-8',$text);//#Attention
$font = 'C:\windows\Fonts\SIMFANG.TTF';
$grey = imagecolorallocate($img, 128, 128, 128);
imagettftext($img, 20, 0, 11, 21, $grey, $font, $text);
imagejpeg($img); //显示灰色的方块
imagedestroy($img);
die("err");
?>报错:
supplied argument is not a valid Image resource 请问要怎么传递 图片的高度 宽度 还有文字 内容??
<form action="img.php" method="post">
<textarea name="word" onpropertychange="this.style.height=this.scrollHeight+'px';" oninput="this.style.height=this.scrollHeight+'px';" style="border:0px;overflow:visible;width:550px;font-size:12px;background-color:#f6f8f9;margin-left:10px; border:solid 1px #E2E2E2;padding:10px 10px;">
想实现Textarea自动适用高度且无滚动条,以下代码可以在IE下正常工作,在FF下基本功能也正常, \r\n
但是在FF下有个小问题:高度可自动增长,但是不能减小,请指教:
代码说明:onpropertychange:IE支持; oninput:FireFox支持;为了兼容IE和FF,所以加上了这个两个;
</textarea><input type="hidden" name="height" value="500" />
<input type="hidden" name="width" value="550" />
<input type="submit" name="提交" value="提交" />
</form>生成图片的源码:<?php
$img = imagecreatetruecolor($POST['height'],$POST['width']); //创建真彩图像资源
$color = imagecolorAllocate($img,255,255,255); //分配一个灰色
imagefill($img,0,0,$color); // 从左上角开始填充灰色
header('content-type:image/jpeg'); //jpg格式
// Add some shadow to the text
$text=$POST['word'];
echo $text;
$text = iconv('gb2312','utf-8',$text);//#Attention
$font = 'C:\windows\Fonts\SIMFANG.TTF';
$grey = imagecolorallocate($img, 128, 128, 128);
imagettftext($img, 20, 0, 11, 21, $grey, $font, $text);
imagejpeg($img); //显示灰色的方块
imagedestroy($img);
die("err");
?>报错:
supplied argument is not a valid Image resource 请问要怎么传递 图片的高度 宽度 还有文字 内容??
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货