Cannot use the generic Request collection after calling BinaryRead
这是我的页面的完整源代码
<% option explicit Response.Expires = -1Server.ScriptTimeout = 600Session.codepage = 65001%><!-- #include file="UploadClass.asp" --><% Dim uploadsDirVar uploadsDirVar = server.MapPath("files_Uploaded") function OutputForm()%><form name="frmSend" method="POST" enctype="multipart/form-data" accept-charset="utf-8" action="form.asp" on@R_403_5555@="return on@R_403_5555@Form();"><input type="hIDden" name="ApplicationForm" value="Insert" />name: <input type="text" name="name_insert" value="" size="30" /> <B>file names:</B><br> file 1: <input name="attach1" type="file" size=35><br> <br> <input type="@R_403_5555@" value="@R_403_5555@"> </form><%end functionfunction TestEnvironment() Dim fso,filename,testfile,streamTest TestEnvironment = "" Set fso = Server.CreateObject("Scripting.fileSystemObject") if not fso.FolderExists(uploadsDirVar) then TestEnvironment = "<B>Folder " & uploadsDirVar & " does not exist.</B><br>The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions." exit function end if filename = uploadsDirVar & "\test.txt" on error resume next Set testfile = fso.CreateTextfile(filename,true) If Err.Number<>0 then TestEnvironment = "<B>Folder " & uploadsDirVar & " does not have write permissions.</B><br>The value of your uploadsDirVar is incorrect. Open uploadTester.asp in an editor and change the value of uploadsDirVar to the pathname of a directory with write permissions." exit function end if Err.Clear testfile.Close fso.Deletefile(filename) If Err.Number<>0 then TestEnvironment = "<B>Folder " & uploadsDirVar & " does not have delete permissions</B>,although it does have write permissions.<br>Change the permissions for IUSR_<I>computername</I> on this folder." exit function end if Err.Clear Set streamTest = Server.CreateObject("ADODB.Stream") If Err.Number<>0 then TestEnvironment = "<B>The ADODB object <I>Stream</I> is not available in your server.</B><br>Check the Requirements page for information about upgrading your ADODB librarIEs." exit function end if Set streamTest = nothingend functionfunction Savefiles Dim Upload,fileSize,ks,i,fileKey Set Upload = New FreeASPUpload Upload.Save(uploadsDirVar) ' If something fails insIDe the script,but the exception is handled If Err.Number<>0 then Exit function Savefiles = "" ks = Upload.Uploadedfiles.keys if (UBound(ks) <> -1) then Savefiles = "<B>files uploaded:</B> " for each fileKey in Upload.Uploadedfiles.keys Savefiles = Savefiles & Upload.Uploadedfiles(fileKey).filename & " (" & Upload.Uploadedfiles(fileKey).Length & "B) " next else Savefiles = "No file selected for upload or the file name specifIEd in the upload form does not correspond to a valID file in the system." end if Savefiles = Savefiles & "<br>Enter a number = " & Upload.Form("enter_a_number") & "<br>" Savefiles = Savefiles & "CheckBox values = " & Upload.Form("checkBox_values") & "<br>" Savefiles = Savefiles & "List values = " & Upload.Form("List_values") & "<br>" Savefiles = Savefiles & "Text area = " & Upload.Form("t_area") & "<br>"end function%><HTML><head><Title>Test Free ASP Upload 2.0</Title><Meta http-equiv="Content-Type" content="text/HTML; charset=utf-8" /><style>BODY {background-color: white;Font-family:arial; Font-size:12}</style><script>function on@R_403_5555@Form() { var formDOMObj = document.frmSend; if (formDOMObj.attach1.value == "") alert("Please press the browse button and pick a file.") else return true; return false;}</script></head><BODY><br><br><div >Upload files to your server</div><%Dim diagnosticsif Request.ServerVariables("REQUEST_METHOD") <> "POST" then diagnostics = TestEnvironment() if diagnostics<>"" then response.write "<div margin-left:20; margin-top:30; margin-right:30; margin-bottom:30;"">" response.write diagnostics response.write "<p>After you correct this problem,reload the page." response.write "</div>" else response.write "<div margin-left:150"">" OutputForm() response.write "</div>" end ifelse response.write "<div margin-left:150"">" OutputForm() response.write Savefiles() response.write "<br><br></div>"end if%></BODY></HTML><!-- #include file="ADOVBS.inc" --><%'=======================================================================================' CONNECT DATABASE'=======================================================================================Dim objConn,objRsSet objConn = CreateObject("ADODB.Connection")Set objRs = CreateObject("ADODB.Recordset")objConn.open"ProvIDer=Microsoft.Jet.olEDB.4.0;Data Source="& server.MapPath("db/Job_database.mdb") &";Mode=ReaDWrite|Share Deny None;Persist Security Info=False"If Request("ApplicationForm") = "Insert" ThenSet InsCom=Server.CreateObject("ADODB.Command")InsCom.ActiveConnection=objConnInsname = Trim(request("name_insert"))Insname = replace(Insname,"'","''")InsCom.CommandText = "Insert into applications(aname)Values(?)"InsCom.Parameters.Append InsCom.CreateParameter("@name_insert",adVarChar,adParaminput,255,Insname)InsCom.ExecuteEnd If%>
我一直在寻找这个问题,但无法使其发挥作用.虽然我发现我必须使用FreeASPUpload提供的Form Collection.因此,我改变了
If Request("ApplicationForm") = "Insert" Then
对此
If Upload.Form("ApplicationForm") = "Insert" Then
但它也会返回一个错误,即:变量未定义:’上传’
如果我更改了Request方法,则只上传文件而不是插入记录
If Request.queryString("ApplicationForm") = "Insert" Then
我理解的是我的插入查询在错误的位置左右…
请帮我解决这个问题..谢谢
解决方法 我没有太多使用AspFreeUpload所以我在这里猜测一下.似乎使用Request对象不是一个选项,所以你不得不使用Upload.Form.正如您的代码所代表的那样,Upload对象仅在Savefiles函数的上下文中定义和设置.
尝试将数据库插入代码移动到Savefiles函数中.这意味着从生产线切割所有东西
Dim objConn,objRs
至
InsCom.Execute
并在“结束功能”之前粘贴它
在调用函数之前,您可能还需要将include adovbs.inc指令移动到某处.最合乎逻辑的地方就是在你的另一个include指令= for uploadclass.asp的正下方
总结以上是内存溢出为你收集整理的表单 – 如何使用FreeASPUpload脚本插入记录和上载文件全部内容,希望文章能够帮你解决表单 – 如何使用FreeASPUpload脚本插入记录和上载文件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)