看板 PHP 關於我們 聯絡資訊
現在我有放表單和顯示影像的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
kerash:第二次開啟的部分,你直接已經把圖片 tag 打出來了 06/06 00:07
kerash:當然開啟已經有 test.jpg ,它就會出現圖了 06/06 00:07
chchwy:最好修改一下標題 06/06 00:18
newton2009:恩恩 改了 06/06 00:21
newton2009:打包 0.0 06/06 00:35
newton2009:修改了QQ 可以到這邊試試看 06/10 22:54
newton2009:http://140.115.217.106/test/index.php 06/10 22:55
newton2009:話說要怎麼設計undo阿QQ 06/10 22:55
※ 編輯: newton2009 來自: 140.115.217.106 (06/10 22:56)