我有一个脚本可以上传图像并传递要由 freeaspupload.php 和我自己处理的表单字段数据。出于某种原因,就在最近,脚本停止了工作。我无法再从我的 2 个表单域中接收数据。
这是我的表单页面。
<!--#include file="includes/open_db_conn.asp"-->
<!--#include file="includes/security_article.asp"-->
<!--#include file="includes/header.asp"-->
<% uid = CInt(Request.QueryString("uid"))
rs.Open "SELECT * FROM landingPage WHERE pageId =" & uid, con %>
<br>
<div class="content">
<% If Request.QueryString("post") = "successful" Then %>
<p style="color:Red">Landing Page Edited Successfully.</p>
<% End If %>
<% If Request.QueryString("uid") > 0 Then %>
<p style="color:Red"><a href="/landingpage.asp?id=<%= Request.QueryString("uid") %>" target="_blank">/landingpage.asp?id=<%= Request.QueryString("uid") %></a></p>
<% End If %>
<p class="header">Edit This Landing Page:</p><br>
<form action="landingpage_process.asp" name="landingForm" method="post" enctype="multipart/form-data">
<input type="hidden" name="pageId" size="30" maxlength="255" value="<%= rs("pageId") %>"/>
<input type="hidden" name="action" value="edit" />
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="30%" align="left" valign="top"><p class="copy">Title:</p></td>
<td width="70%" align="left" valign="top"><p class="copy"><input type="text" name="pageTitle" size="30" value="<%= rs("pageTitle") %>" /></p></td>
</tr>
<tr>
<td width="30%" align="left" valign="top"><p class="copy">Banner Image:</p></td>
<td width="70%" align="left" valign="top"><p class="copy"><input type="file" name="pageBanner" size="30" /></p>
<img src="../images/pages/<%= rs("pageBanner") %>" alt="" style="max-height:75px;" /></td>
</tr>
<tr>
<td align="left" valign="top" colspan="2"><p class="copy">Left Column:</p><p class="copy">
<textarea id="pageLeftColumn" name="pageLeftColumn"><%= Replace(rs("pageLeftColumn"), "&", "&") %></textarea>
</p></td>
</tr>
<tr>
<td align="left" valign="top" colspan="2"><p class="copy">Right Column (Leave blank for one large left column)</p><p class="copy">
<textarea id="pageRightColumn" name="pageRightColumn"><%= Replace(rs("pageRightColumn"), "&", "&") %></textarea>
</p></td>
</tr>
<tr>
<td align="center" valign="top" colspan="2"><center><input type="submit" value="Edit Page" /></center></td>
</tr>
</table>
</form>
</div>
<!--#include file="includes/footer.asp"-->
<!--#include file="includes/close_db_conn.asp"-->
这是用于处理的页面:
<%@ Language=VBScript %>
<%
option explicit
Response.Expires = -1
Server.ScriptTimeout = 600
' All communication must be in UTF-8, including the response back from the request
Session.CodePage = 65001
%>
<!-- #include file="includes/freeaspupload.asp" -->
<!-- #include file="includes/ChkString.asp"-->
<!-- #include file="includes/open_db_conn.asp"-->
<%
Dim action, returnPage
action = "add"
returnPage = "landingpage_add.asp"
Dim uploadsDirVar
uploadsDirVar = "C:\inetpub\colloquy.com\images\pages"
function 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 = Nothing
end function
Dim test
Dim varStrings
Dim imageArray
Dim item
Dim tempArray
Dim fields
Dim values
Dim sql_add
function SaveFiles
Dim Upload, fileName, fileSize, ks, i, fileKey
on error resume next
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
'Response.Write(Err.Description)
End If
SaveFiles = ""
ks = Upload.UploadedFiles.keys
if (UBound(ks) <> -1) then
for each fileKey in Upload.UploadedFiles.keys
SaveFiles = SaveFiles & fileKey & "=>" & Upload.UploadedFiles(fileKey).FileName & "<|>"
next
end if
action = Upload.Form("action")
leftColumn = Upload.Form("pageLeftColumn")
Response.Write(leftColumn)
SaveFiles = SaveFiles & "pageTitle=>" & Upload.Form("pageTitle") & "<|>"
SaveFiles = SaveFiles & "pageLeftColumn=>" & Upload.Form("pageLeftColumn") & "<|>"
SaveFiles = SaveFiles & "pageRightColumn=>" & Upload.Form("pageRightColumn")
If action = "edit" Then
SaveFiles = SaveFiles & "<||>"
SaveFiles = SaveFiles & Upload.Form("pageId")
End If
end function
fields = ""
values = ""
test = TestEnvironment()
If len(test) < 1 Then
varStrings = SaveFiles()
Response.Write(varStrings)
Response.End()
If action = "add" Then
imageArray = Split(varStrings,"<|>")
For Each item In imageArray
tempArray = Split(item,"=>")
fields = fields & tempArray(0) & ", "
values = values & "'" & Server.HTMLEncode(replaceQuotes(tempArray(1))) & "', "
Next
fields = fields & "dateAdded"
values = values & "'" & Now() & "'"
on error resume next
sql_add = "Insert Into landingPage (" & fields & ") Values (" & values & ");"
con.Execute sql_add
Dim rsIdentity 'a recordset to hold the identity value
'This line of code will get us the indentity value for the row
' we just inserted!!
Set rsIdentity = con.Execute("SELECT @@IDENTITY AS NewID")
returnPage = "landingpage_add.asp?uid=" & rsIdentity("NewID")
If err<>0 Then
response.write("<p class=""header"">Error!</p><p class=""copy"">The record was not saved, please try again.</p><p class=""copy"">" & err.Description & "</p><p class=""copy"">" & sql_add & "</p>")
End If
End If
If action = "edit" Then
Dim Array1
Dim Array2
Array1 = Split(varStrings,"<||>")
Array2 = Split(Array1(0),"<|>")
imageArray = Split(varStrings,"<|>")
Dim comma
comma = ""
For Each item In Array2
tempArray = Split(item,"=>")
fields = fields & comma & tempArray(0) & "='" & Server.HTMLEncode(replaceQuotes(tempArray(1) & "")) & "'"
comma = ", "
Next
fields = fields & " Where pageId=" & Array1(1)
returnPage = "landingpage_edit.asp?uid=" & Array1(1)
on error resume next
sql_add = "Update landingPage Set " & fields & ";"
''Response.Write(sql_add)
con.Execute sql_add
If err<>0 Then
response.write("<p class=""header"">Error!</p><p class=""copy"">The record was not saved, please try again.</p><p class=""copy"">" & err.Description & "</p><p class=""copy"">" & sql_add & "</p>")
End If
End If
End If
%>
<!--#include file="includes/close_db_conn.asp"-->
<%
If err=0 Then
Response.Redirect returnPage & "&post=successful"
End If
%>
Response.Write(varStrings)
底部的给我:
pageTitle=>2013 COLLOQUY Awards Ceremony Video<|>pageLeftColumn=><|>pageRightColumn=><||>46
如您所见,左侧或右侧列没有数据,尽管我在这些字段中确实有信息。
我尝试将我的文本区域更改为输入,但这也不起作用(我希望它会因为标题字段仍然通过)。