我想允许用户插入文本并将其添加到图像然后下载图像 本地一切都很完美,但是当我将代码上传到服务器时,它并不起作用 任何想法??
<html>
<body>
<form method="POST" action="process.php">
<input type="text" name="username"/>
<br> <br>
<input type="text" name="username2"/>
<br> <br>
<input type="submit" name="subpic" />
</form>
<?php
if (isset($_GET['name'])&&isset($_GET['x'])) {
$file = " ".$_GET['name']."".$_GET['x'].".jpg";
echo "<a href='process2.php?name=".$file."'>download</a> ";
}
?>
</body>
</html>
流程代码
<?php
$rImg = ImageCreateFromJPEG("doctor.jpg");
$cor = imagecolorallocate($rImg, 255, 0, 0);
$user = $_POST['username'];
$user2 = $_POST['username2'];
$font = 'roboto.ttf';
imagettftext($rImg, 39.5, 0, 155, 719, $cor, $font, $user);
imagettftext($rImg, 39.5, 0, 155, 780, $cor, $font, $user2);
header('Content-type: image/jpeg');
imagejpeg($rImg, " ".$user."".urldecode($_GET['x']).".jpg");
header('location:main.php?name='.$user.'&x='.$_GET['x'].'');
?>
和process2代码是:
<?php
$name= $_GET['name'];
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header("Content-Disposition: attachment; filename=\"" . basename($name) . "\";");
header('Content-Transfer-Encoding: image/jpeg');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($name));
ob_clean();
flush();
readfile($name); //showing the path to the server where the file is to be download
exit;
?>