|
|
|
ติด Cannot use Request.Form collection after calling BinaryRead. ต้องแก้ยังไงครับ |
|
|
|
|
|
|
|
มันแจ้งว่าเราติด
Code
Request object error 'ASP 0207 : 80004005'
Cannot use Request.Form
/test/user/insertnews.asp, line 81
Cannot use Request.Form collection after calling BinaryRead.
ต้องแก้ยังไงครับ ขอละเอียดนิดหนึ่งนะครับ เพราะผมต้องรีบใช้แล้วอ่ะ
Form(ASP)
<%
if Session("user")="" then
Response.Redirect("../login.asp")
end if
%>
<!--#include file="userheader.asp"-->
<!--#include file="usermenu.asp"-->
<td class="f2">
<script language="javascript">
Function init()
{
if (document.innew.txttile.value == "")
{
alert("กรุณาใส่หัวข้อข่าวด้วย");
document.innew.txttile.focus();
return false;
}
if (document.innew.txtdetail.value == "")
{
alert("กรุณาใส่รายละเอียดด้วยด้วย");
document.innew.txtdetail.focus();
return false;
}
if (document.innew.txttype.value == "")
{
alert("กรุณาใส่ส่วนงานด้วย");
document.innew.txttype.focus();
return false;
}
document.innew.sumbit();
}
</script>
<form action="insertnews.asp" method="post" name="innew" onsubmit="return init()" enctype="multipart/form-data" >
<table width="80%" border="1" style="width:50%">
<th colspan="2" align="center"> เพิ่มข่าวใหม่</th>
<tr>
<td valign="top">หัวข้อข่าว</td>
<td><input name="txttitle" type="text" size="80" /> </td>
</tr>
<tr>
<td valign="top">รายละเอียดข่าว</td>
<td><textarea name="txtdetail" cols="80" rows="5"></textarea></td>
</tr>
<tr>
<td valign="top">ส่วนประกาศ</td>
<td><select name="txtcall">
<option value="ข่าวประชาสัมพันธ์" selected="selected">ข่าวประชาสัมพันธ์</option>
<option value="ข่าวประกาศ">ข่าวประกาศ</option>
<option value="ข่าวการศึกษาก่อนปริญญา">ข่าวการศึกษาก่อนปริญญา</option>
<option value="ข่าวการศึกษาหลังปริญญา">ข่าวการศึกษาหลังปริญญา</option>
</select></td>
</tr>
<tr>
<td valign="top">หมายเหตุ</td>
<td><input name="txtetc" type="text" size="80" /> </td>
</tr>
<tr>
<td valign="top">ส่วนงาน</td>
<td><select name="txttype">
<option value="" selected="selected">กรุณาเลือก</option>
<%
dim sqltype,rectype
sqltype="select * from unit "
set rectype=Server.CreateObject("ADODB.Recordset")
rectype.open sqltype,con
while not rectype.EOF
%>
<option value="<%=rectype.fields("unitid").value%>" ><%=rectype.fields("unitname").value%></option>
<%
rectype.movenext
wend
rectype.close()
set rectype=nothing
%>
</select> </td>
</tr>
<tr>
<td valign="top">เอกสารแนบ</td>
<td><input name="file1"type="file" size="80" /> </td>
</tr>
<tr>
<td colspan="2" align="center">
<input name="submit" type="submit" value="บันทึก" />
<input name="Reset" type="reset" value="ยกเลิก" />
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<!--#include file="footer.asp" -->
upload(ASP)
<!--#include file="connect.asp"-->
<%
Dim mySmartUpload
'*** Create Object ***'
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
'*** Upload Files ***'
mySmartUpload.Upload
'*** Upload file1 ***'
If mySmartUpload.Files("file1").FileName <> "" Then
mySmartUpload.Files("file1").SaveAs(Server.MapPath("uploads/" & mySmartUpload.Files("file1").FileName))
'Response.write mySmartUpload.Files("file1").Name & " Uploaded."
End If
'*** Upload file2 ***'
'If mySmartUpload.Files("file2").FileName <> "" Then
' mySmartUpload.Files("file2").SaveAs(Server.MapPath("uploads/" & 'mySmartUpload.Files("file2").FileName))
' Response.write mySmartUpload.Files("file2").Name & " Uploaded."
'End IF
'*** Properties ***'
'Response.Write("Name = " & mySmartUpload.Files("file1").Name & "<BR>")
'Response.Write("Size = " & mySmartUpload.Files("file1").Size & "<BR>")
'Response.Write("FileName = " & mySmartUpload.Files("file1").FileName & "<BR>")
'Response.Write("FileExt = " & mySmartUpload.Files("file1").FileExt & "<BR>")
'Response.Write("FilePathName = " & mySmartUpload.Files("file1").FilePathName & "<BR>")
'Response.Write("ContentType = " & mySmartUpload.Files("file1").ContentType & "<BR>")
'Response.Write("ContentDisp = " & mySmartUpload.Files("file1").ContentDisp & "<BR>")
'Response.Write("TypeMIME = " & mySmartUpload.Files("file1").TypeMIME & "<BR>")
'Response.Write("SubTypeMIME = " & mySmartUpload.Files("file1").SubTypeMIME & "<BR>")
Function DateThai(strDate)
Setlocale("en-us")
Dim strDay,strMonth,strYear,strHour,strMinute,strSecond
Dim arrMonth
strDay = Day(strDate)
strMonth = Month(strDate)
strYear = Year(strDate)
arrMonth = Array("เธก.เธ.","เธ.เธ.","เธกเธต.เธ","เน€เธก.เธฉ.","เธ.เธ.","เธกเธด.เธข.","เธ.เธ.","เธช.เธ.","เธ.เธข.","เธ•.เธ.","เธ.เธข.","เธ.เธ.")
DateThai = strDay &" "&arrMonth(strMonth-1) &" "&strYear
End Function
dim d,t
d=date()
t=DateThai(d)
Function max(maxs)
dim msql,mrec
msql="select max(" & maxs & ") as idmax from news"
set mrec=con.execute(msql)
if not mrec.EOF then
max=mrec.fields("idmax").value
end if
End Function
dim idm,maxs
maxs="newsid"
idm=max(maxs)+1
Function user(us)
dim usel,urec
usel="select * from officer where of_username='" & us & "' "
set urec=con.execute(usel)
if not urec.EOF then
user=urec.fields("of_name").value
end if
End Function
dim uses,us
us=Session("user")
uses=user(us)
dim uploads
uploads=
dim insql,inrec
insql="insert into news values ('" & idm & "','" & Request.Form("txttitle") & "','" & Request.Form("txtdetail") & "','" & Request.Form("txtcall") & "','" & mySmartUpload.Files("file1").FileName & "','" & Request.Form("txtetc ")& "','" & Request.Form("txttype ")& "','" & t & "','" & uses & "')"
set inrec=con.Execute(insql)
Response.Write(insql)
'response.Redirect("usernew.asp")
con.close()
urec.close()
mrec.close()
inrec.close()
set con= nothing
set inrec= nothing
Set mySmartUpload = Nothing
%>
Tag : ASP
|
|
|
|
|
|
Date :
2012-01-16 10:40:01 |
By :
Clamore |
View :
2041 |
Reply :
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คุณส่งไปแบบ Binary [enctype="multipart/form-data] ครับ อ่าน Request.Form ไม่ได้ครับ
ให้ใช้ mySmartUpload.Form("txt1") ครับ เช่น
Code (ASP)
mySmartUpload.Form("txttitle")
Go to : ASP aspSmartUpload - Upload and Other Element
|
|
|
|
|
Date :
2012-01-16 11:19:34 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
insert into news values ('34','?????','sd','??????????','?????','33','freeASPUpload.zip','16 เน€เธ�เธ�.เน€เธ�ย�. 2012','10')
select * from officer where of_username='root'
Microsoft VBScript runtime error '800a01a8'
Object required: ''
/test/user/insertnews.asp, line 96
ขึ้นยังงี้หมายความว่ายังไงอ่ะครับ
แล้วมีวิธีแก้ให้มันอ่านเป็นภาษาไทยไหมอ่ะครับ
|
|
|
|
|
Date :
2012-01-16 13:08:27 |
By :
Clamore |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เออเรอไลที่ 96 อ่ะครับ
ส่วนโค้ดก็ตามข้างบนเลย
|
|
|
|
|
Date :
2012-01-16 14:06:09 |
By :
Clamroe |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตรง mrec.close() ครับ
ส่วน insert ผมก็ยัง อิน ไม่ได้ซักทีอ่ะ
ลองทั้ง session codepage ="874"
response charset="tis-620"
ก็ยังไม่ได้ซักทีอ่ะ
|
|
|
|
|
Date :
2012-01-16 14:55:06 |
By :
Clamore |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (ASP)
IF IsObject(mrec) Then mrec.close()
|
|
|
|
|
Date :
2012-01-16 15:04:55 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|