2013-10-26 5 views
0

새로 고침 후 다시 제출 PHP 페이지 - 이유새로 고침 후 다시 제출 PHP 페이지 - 이유

왜?

새로 고침 후 다시 제출하고 싶지 않습니다!

어떤 도움이 필요합니까?

내가 더 솔루션

을 시도하지만 모든 솔루션은 유효하지 않습니다!

당신이 나를 도와 내 코드를 편집

솔루션

하시기 바랍니다 ..

감사가있는 경우 내 코드,

입니다.

이 내 양식 코드

<form id="uploadedfile" name="uploadedfile" enctype="multipart/form-data" action="upload.php" method="POST"> 
<input name="uploadedfile" type="file" /> 
<input type="submit" value="upload" /> 
</form> 

이 upload.php로 코드입니다 : 각 양식 후

<?php 
$allowedExts = array("gif", "jpeg", "jpg", "png", "zip", "pdf", "docx", "rar", "txt", "doc"); 
$temp = explode(".", $_FILES["uploadedfile"]["name"]); 
$extension = end($temp); 
$newname = $extension.'_'.substr(str_shuffle(str_repeat("abcdefghijklmnopqrstuvwxyz", 7)), 4, 7); 
$imglink = 'attachment/attachment_file_'; 
$uploaded = $imglink .$newname.'.'.$extension; 
if ((($_FILES["uploadedfile"]["type"] == "image/jpeg") 
|| ($_FILES["uploadedfile"]["type"] == "image/jpeg") 
|| ($_FILES["uploadedfile"]["type"] == "image/jpg") 
|| ($_FILES["uploadedfile"]["type"] == "image/pjpeg") 
|| ($_FILES["uploadedfile"]["type"] == "image/x-png") 
|| ($_FILES["uploadedfile"]["type"] == "image/gif") 
|| ($_FILES["uploadedfile"]["type"] == "image/png") 
|| ($_FILES["uploadedfile"]["type"] == "application/msword") 
|| ($_FILES["uploadedfile"]["type"] == "text/plain") 
|| ($_FILES["uploadedfile"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") 
|| ($_FILES["uploadedfile"]["type"] == "application/pdf") 
|| ($_FILES["uploadedfile"]["type"] == "application/x-rar-compressed") 
|| ($_FILES["uploadedfile"]["type"] == "application/x-zip-compressed") 
|| ($_FILES["uploadedfile"]["type"] == "application/zip") 
|| ($_FILES["uploadedfile"]["type"] == "multipart/x-zip") 
|| ($_FILES["uploadedfile"]["type"] == "application/x-compressed") 
|| ($_FILES["uploadedfile"]["type"] == "application/octet-stream")) 
&& ($_FILES["uploadedfile"]["size"] < 5242880) // Max size is 5MB 
&& in_array($extension, $allowedExts)) 
{ 
move_uploaded_file($_FILES["uploadedfile"]["tmp_name"], 
$uploaded); 
echo '<a target="_blank" href="'.$uploaded.'">click</a>'; 
echo '<h3>'.$uploaded.'</h3>'; 
} 
if($_FILES["uploadedfile"]["error"] > 0){ 
echo '<h3>Please choose file to upload it!</h3>'; // If you don't choose file 
} 
elseif(!in_array($extension, $allowedExts)){ 
echo '<h3>This extension is not allowed!</h3>'; // If you choose file not allowed 
} 
elseif($_FILES["uploadedfile"]["size"] > 5242880){ 
echo "Big size!"; // If you choose big file 
} 
?> 
+0

작업을 볼 수 있도록 양식을 추가 할 수 있습니까? –

+0

조금 설명해 주시겠습니까? –

+0

나는 그것을 편집, 내 양식 코드를 참조 – user2719452

답변

0

음,

이 포스트 데이터가 세션에 남아 제출합니다. 이 방법으로 스크립트를 수행 할 수 있습니다.

방법 1 :

unset($_POST); 
unset($_FILES); 
unset($_REQUEST); 

을 또는 당신이 할 ca를

header('Location:[YOUR URL]'); 

경우 [당신의 URL] 당신은 파일 업로드가 처리 된 후 가고 싶은 URL이 될 것입니다.

이후에는 제출 된 데이터가 더 이상 보존되지 않습니다.

+0

나는 그것을 시도,이 잘못되었습니다, 제발 도와주세요 내 코드를 편집하십시오. – user2719452

관련 문제