我正在使用以下内容在pdf上放置签名。 img,img2,&我的表单上的img3字段包含签名作为字符串。只要所有3个字段都包含数据/签名,它就能完美运行。如果有任何空白,脚本将停在
file_put_contents($image, base64_decode($arr[1]));
当我没有签署一个或多个签名时,Firebug确认没有为该字段发送postdata。所以我必须在php中做错事。
如果引用的字段为空,下面的代码是否应该停止所有图像处理?
有没有不同的方法来实现这一目标?
感谢您的帮助!
require_once('fpdf/fpdf.php');
require_once('fpdi/fpdi.php');
$pdf = new FPDI('P', 'mm', 'Letter');
$pagecount = $pdf->setSourceFile($ffn);
for($i = 1 ; $i <= $pagecount ; $i++){
$tpl = $pdf->importPage($i);
$pdf->AddPage();
$pdf->useTemplate($tpl, 0, 0);
if ($i==7) {
if(isset($_POST['img'])){
$hash = uniqid();
$arr = explode(',',$_POST['img']);
$image = dirname(__FILE__).'/results/sig'.$hash.'.png';
file_put_contents($image, base64_decode($arr[1]));
$pdf->Image($image,38,193,-200);
};
if(isset($_POST['img2'])){
$hash2 = uniqid();
$arr2 = explode(',',$_POST['img2']);
$image2 = dirname(__FILE__).'/results/sig'.$hash2.'.png';
file_put_contents($image2, base64_decode($arr2[1]));
$pdf->Image($image2,38,217,-200);
};
if(isset($_POST['img3'])){
$hash3 = uniqid();
$arr3 = explode(',',$_POST['img3']);
$image3 = dirname(__FILE__).'/results/sig'.$hash3.'.png';
file_put_contents($image3, base64_decode($arr3[1]));
$pdf->Image($image3,38,241,-200);
};
};
if ($i==8) {
$locmap = $_POST['_fid_209'];
$pdf->Image('http://maps.googleapis.com/maps/api/staticmap?markers=color:blue%7Clabel:I%7C'.$locmap.'&zoom=14&size=800x800&sensor=false',63,90,90,0,'PNG');
};
}
$pdf->Output($ffn, 'F');
答案 0 :(得分:1)
if(isset($_POST['img']) && !empty($_POST['img'])) {
...