作者newton2009 (~好瘦的鲁蛇~)
看板PHP
标题[请益] 问这个 不知道会不会被笑 0.0
时间Wed Jun 5 23:28:34 2013
现在我有放表单和显示影像的form.html、二个处理用的A.php和B.php
form.html的板面这样
--------------------
- 表单A - -
--------- 显示影像 -
- 表单B - -
--------------------
A.php用来上传jpg影像,并命名为test.jpg
B.php用来旋转test.jpg影像
情形大概像这样:
第一次开form.html
form.html A.php B.php
POST
表单A -------> 上传影像
-
-
显示影像(出现) <---header
-
- POST
表单B -----------------------------------------> 旋转影像
-
-
显示影像(旋转过後的影像有出现,看起来是正常的) <------header
-
- POST
表单B -----------------------------------------> 旋转影像
-
-
显示影像(旋转的
影像黑底变大了= =...) <----------------header
第二次 第一次关掉後,在重开form.html
还没上传,显示影像的部分就跑出来了QQ
要怎麽处理这两个问题(红色文字)呢~~
以下是程式码:
form.html
<!doctype html>
<meta charset="utf-8">
<table border="1" cellspacing="0" cellpadding="10" style="width:100%"><tr>
<td>
<form action="A.php" method="post" enctype="multipart/form-data">
Please upload a JPG image:<br>
<input type="file" name="fileupload"><br>
<input type="submit" value="Upload">
</form>
</td>
<td rowspan="2" align="center" style="width:60%">
<img src="test.jpg">
</td>
</tr><tr>
<td>
<form action="B.php" method="post">
Rotate CCW angle(between 0 and 359 degrees):
<input type="number" name="degrees" min="0" max="359">
<input type="submit" value="Apply">
</form>
</td>
</tr></table>
A.php
<?php
if ( !in_array($_FILES["fileupload"]['type'],
array("image/jpeg","image/pjpeg")) )
{
header("Location: form.html");
}
else
{
if( $_FILES["fileupload"]["error"]==0 )
{
@file_put_contents("test.jpg",
file_get_contents($_FILES["fileupload"]["tmp_name"]));
header("Location: form.html");
}
}
?>
B.php
<?php
$filename = "test.jpg";
$degrees = $_POST["degrees"];
$source = imagecreatefromjpeg($filename);
$rotate = imagerotate($source, $degrees, 0);
imagejpeg($rotate, $filename);
imagedestroy($source);
imagedestroy($rotate);
header("Location: form.html")
?>
感恩QAQ
--
╭───────────────────╮
│ 我要努力, │
│ 跳出 我的 │ 框框
╰───────────────────╯
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.115.217.106
1F:→ kerash:第二次开启的部分,你直接已经把图片 tag 打出来了 06/06 00:07
2F:→ kerash:当然开启已经有 test.jpg ,它就会出现图了 06/06 00:07
3F:推 chchwy:最好修改一下标题 06/06 00:18
4F:→ newton2009:恩恩 改了 06/06 00:21
5F:→ newton2009:打包 0.0 06/06 00:35
7F:→ newton2009:修改了QQ 可以到这边试试看 06/10 22:54
9F:→ newton2009:话说要怎麽设计undo阿QQ 06/10 22:55
※ 编辑: newton2009 来自: 140.115.217.106 (06/10 22:56)