2013-01-24 2 views
0

PHP 문의 양식에 업로드 및 제출 버튼이 있지만 파일 업로드를 위해 제출을 클릭하면이 제출 버튼이 전체 양식을 제출하므로 메인 제출 버튼. 따라서 사용자는 파일을 업로드 할 수 없습니다. 파일 제출이 전체 양식을 제출하지 않도록하려면 어떻게해야합니까?문의 양식의 업로드 양식은 업로드 양식 제출이 전체 양식을 계속 제출합니다.

<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" > 
<tr> 



<tr> 
<td> 
<!-- start here--> 


<form action="contactform.php" method="post"> 
<table class="freecontact2form" border="0" width="400px"> 
<tbody> 
<tr> 
<td colspan="2"><span style="font-size: x-small;"> </span> <br /> <br /></td> 
</tr> 

<tr> 
<td>Question 1<br> 
    <br></td> 
</tr> 

<tr> 
<td><br> 

    Answer 1 <input type="radio" name="ans" value="ans1" /><br /> 
    Answer 2 <input type="radio" name="ans" value="ans2" /><br /> 
    Answer 3 <input type="radio" name="ans" value="ans3" /><br /> 
    Answer 4 <input type="radio" name="ans" value="ans4" /><br /> 

</td> 
    </tr> 

</tr> 

<!--upload form Start here--> 


<form action="upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> 
<td> 
<table width="100%" border="0" cellpadding="3" cellspacing="1" > 
<tr> 
<td><strong>Upload form/strong></td> 

</tr> 

<tr> 
<td>Below is for file upload:<br> 
    <br></td> 
</tr> 

<tr> 
<td>Select file 
<input name="ufile" type="file" id="ufile" size="50" /></td> 
</tr> 



<tr> 
<td align="center"><input type="submit" name="Submit" value="Upload" /></td> 
</tr> 
</form> 

<!--upload formend here--> 





<tr> 
<td style="text-align:center" colspan="2"><br /><br /> <input src="submit1.png" name="submit" type="image"> <br /><br /> 


<br /><br /></td> 
</tr> 
</tbody> 
</table> 
</form> 


<!-- end here --> 

</td> 
</tr> 

</table> 
</td> 

</tr> 
</table> 

답변

1

코드에 현재 다른 양식으로 묶인 양식이 포함되어있어 작동하지 않습니다. 양식을 중첩 할 수 없습니다.

현재 코드 :

<form action="contactform.php" method="post"> 
... 
<form action="upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> 
... 
</form> 
... 
</form> 

대신이 코드를 봅니다 :

<form action="contactform.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> 
Here you must add all the fields of the two previous forms. 
</form> 

또한 upload_ac.php에서 contactform.php에 PHP 코드를 이동해야합니다.

이 새로운 양식을 제출하면됩니다

  • 이 필드의 값 $_POST을 채울 선택한 파일을 업로드