Copy link to clipboard
Copied
If I use a File Field in a form and an Insert Record Behaviour, the page computes for a while and then reloads itself as an empty page (no form fields filled in.) If I change the File Field to a Text Field, it works okay (inserts the record and goes the the page specified in the Insert Record behaviour.
Any help?
Copy link to clipboard
Copied
Not sure what you mean by File Field. Are you trying to upload a file to the server to insert into the database? If so, do you actually have an upload script that is working? Also, inserting files into the database is usually not the preferred way to do things - better to store a path to the file instead. Sorry if I am misunderstanding your problem. Please clarify if that is the case.
Copy link to clipboard
Copied
One of the choices when you are building a form is to go to Insert >
Form > File Field. It gives you a Browse button next the the field to
select a file name. I am not storing the file in a database, I am
storing the name of the file. I have a separate script that uploads the
file that works fine. This same page has been working well for a long
time, but it was developed with Dreamweaver CS3. The problem began when
I edited the page with Dreamweaver CS4.
Thanks for the quick response.
Bill
Copy link to clipboard
Copied
If you are using file field, make sure u set the form properties for enctype as 'multipart/form-data'.
Copy link to clipboard
Copied
Yep, it is set properly.
Bill
Copy link to clipboard
Copied
Owh, okay. Anyway I guess, the blank page appearred because u didnt set the error to be showed on page. I remembered David Powers had said so before. But I cant remember in which thread. But maybe u can show ur code here, maybe someone could help.
Copy link to clipboard
Copied
I have attached what works and what does not.
PhotoInsert2.asp works.
PhotoInsert3.asp does not work.
Bill
Copy link to clipboard
Copied
Looks like the attachments did not make it. I'll try again.
PhotoInsert2.asp works.
PhotoInsert3.asp does not work.
Thanks,
Bill
Copy link to clipboard
Copied
this code works
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include virtual="/Connections/cnPetanque.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
If (CStr(Request("MM_insert")) = "form1") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_cnPetanque_STRING
MM_editCmd.CommandText = "INSERT INTO Photos (PhotoCaption, PhotoLink, PhotoTitle, PhotoURL) VALUES (?, ?, ?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 50, Request.Form("PhotoCaption")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 50, Request.Form("PhotoLink")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 50, Request.Form("PhotoTitle")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 50, Request.Form("PhotoURL")) ' adVarWChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "/PhotoMaintenance.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End If
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="<%=MM_editAction%>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">PhotoCaption:</td>
<td><input type="text" name="PhotoCaption" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">PhotoLink:</td>
<td><input type="text" name="PhotoLink" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">PhotoTitle:</td>
<td><input type="text" name="PhotoTitle" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">PhotoURL:</td>
<td><input type="text" name="PhotoURL" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</body>
</html>
this code does not work.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include virtual="/Connections/cnPetanque.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
If (CStr(Request("MM_insert")) = "form1") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_cnPetanque_STRING
MM_editCmd.CommandText = "INSERT INTO Photos (PhotoCaption, PhotoLink, PhotoTitle, PhotoURL) VALUES (?, ?, ?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 50, Request.Form("PhotoCaption")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 50, Request.Form("PhotoLink")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 50, Request.Form("PhotoTitle")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 50, Request.Form("fmFilename")) ' adVarWChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "/PhotoMaintenance.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End If
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="<%=MM_editAction%>" method="POST" enctype="multipart/form-data" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">PhotoCaption:</td>
<td><input type="text" name="PhotoCaption" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">PhotoLink:</td>
<td><input type="text" name="PhotoLink" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">PhotoTitle:</td>
<td><input type="text" name="PhotoTitle" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">PhotoURL:</td>
<td><input type="file" name="fmFilename" id="fmFilename" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</body>
</html>