Re: [請益] 圖片上傳問題..

看板PHP作者 (凝視)時間17年前 (2009/01/15 13:11), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
※ 引述《kgfu (好想睡阿!)》之銘言: : 基本上我寫的圖片上傳都OK,也正常的work! : 但是我發現一個問題,如果我按F5重新整理,它似乎不會還原到一開始的網頁 : 反而又上傳同樣的圖片一次>"<找不到頭緒解決這個問題.. : 下面是我一部分的程式碼 因為你按下 F5 他就會重作一次妳的動作,包含 post 這個動作。 : <form enctype="multipart/form-data" method="post" name="upform"> : <input name="upfile" type="file"> : <input type="submit" value="上傳"> : </form> : --------------------------- 以上這段表單搬到網頁最後面。 : <?php $msg = null; : if ($_SERVER['REQUEST_METHOD'] == 'POST') { 或是 if(isset($_POST['upfile'])) { : $filename=$file["tmp_name"]; : $image_size = getimagesize($filename); : $pinfo=pathinfo($file["name"]); : $ftype=$pinfo[extension]; : $destination = $destination_folder.time().".".$ftype; : if (file_exists($destination) && $overwrite != true) msg .= "<font color='red'>同名文件已經存在了!</a>"; : if(!move_uploaded_file ($filename, $destination)) msg .= "<font color='red'>移動文件出錯!</a>"; if($msg == null) header("Location: $_SERVER['PHP_SELF']"); else echo $msg; // 可以簡單的避免你的問題。 : } : ?> : -------- : 我自己猜測可能問題點在 : $_SERVER['REQUEST_METHOD'] == 'POST' : 上面... 不是~ -- 凝視著,卻看不見光景。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 211.23.32.124 ※ 編輯: roga 來自: 211.23.32.124 (01/15 13:12)
文章代碼(AID): #19RiLdMN (PHP)
文章代碼(AID): #19RiLdMN (PHP)