File upload into database doesn't work

D

dodger741

I am a new user of FP 2003 and am trying to host my web pages on
GoDaddy.com

I have been trying to create a web page using the database wizard to
create a form to enter user information and ultimately to allow the
user to upload a file (picture) to the database. I was successful in
creating a simple form to enter name and address and got this to work
after many trial and error exercises. The last one that made it work
is to use the directory created by GoDaddy to store my database in.
When I added an upload box/button to my form everything died. After
entering data and submitting, the form just clears, doesn't even go
the the confirmation page. I created a directory on the server to
substitute for the "picupload" directory created by Frontpage and
tried all the combinations of privileges allowed with no effect. When
I enter data manually into the upload database I do see it in the
results page which I think indicates the database connection is ok??

I have been playing with this for days with no closure. Any
suggestions would be greatly appreciated. Is there a way to get error
messages from the hosting site when are encountered?? I do not see
any kind of error messages for the page that doesn't work.

************************************CODE WITH NO UPLOAD BUTTON -
works********************

<%
' FP_ASP ASP Automatically generated by a FrontPage Component. Do not
Edit.

On Error Resume Next
Session("FP_OldCodePage") = Session.CodePage
Session("FP_OldLCID") = Session.LCID
Session.CodePage = 1252
Err.Clear

strErrorUrl = ""

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("VTI-GROUP") = "0" Then
Err.Clear

Set fp_conn = Server.CreateObject("ADODB.Connection")
FP_DumpError strErrorUrl, "Cannot create connection"

Set fp_rs = Server.CreateObject("ADODB.Recordset")
FP_DumpError strErrorUrl, "Cannot create record set"

fp_conn.Open Application("database1_ConnectionString")
FP_DumpError strErrorUrl, "Cannot open database"

fp_rs.Open "Results", fp_conn, 1, 3, 2 ' adOpenKeySet,
adLockOptimistic, adCmdTable
FP_DumpError strErrorUrl, "Cannot open record set"

fp_rs.AddNew
FP_DumpError strErrorUrl, "Cannot add new record set to the database"
Dim arFormFields0(2)
Dim arFormDBFields0(2)
Dim arFormValues0(2)

arFormFields0(0) = "Name"
arFormDBFields0(0) = "Name"
arFormValues0(0) = Request("Name")
arFormFields0(1) = "Address"
arFormDBFields0(1) = "Address"
arFormValues0(1) = Request("Address")

FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0

If Request.ServerVariables("REMOTE_HOST") <> "" Then
FP_SaveFieldToDB fp_rs, Request.ServerVariables("REMOTE_HOST"),
"Remote_computer_name"
End If
If Request.ServerVariables("HTTP_USER_AGENT") <> "" Then
FP_SaveFieldToDB fp_rs, Request.ServerVariables("HTTP_USER_AGENT"),
"Browser_type"
End If
FP_SaveFieldToDB fp_rs, Now, "Timestamp"
If Request.ServerVariables("REMOTE_USER") <> "" Then
FP_SaveFieldToDB fp_rs, Request.ServerVariables("REMOTE_USER"),
"User_name"
End If

fp_rs.Update
FP_DumpError strErrorUrl, "Cannot update the database"

fp_rs.Close
fp_conn.Close

FP_FormConfirmation "text/html; charset=windows-1252",_
"Form Confirmation",_
"Thank you for submitting the following information:",_
"submission_form.asp",_
"Return to the form."

End If
End If

Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")

%>
<% Response.Buffer = True %>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>Results -- New</title>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

<body bgcolor="#FFFFFF">

<table width="100%" align=left>
<tr>
<td width="50%">
<b><font size=+3 color="#000080"> Submission Form </font></b>
</td>
<td width="50%" align=right>
<table>
<tr>
<td>
<a href="../results_page.asp" target="_top">Results Page</a> |
Submission Form

</td>
</tr>
</table>
</td>
</tr>
</table>


<p>
<br clear="all">
<hr>
<p>

<form METHOD="POST" action="--WEBBOT-SELF--" onsubmit="return
FrontPage_Form1_Validator(this)" language="JavaScript"
name="FrontPage_Form1">

<!--webbot bot="SaveDatabase" SuggestedExt="asp" S-
DataConnection="database1" S-RecordSource="Results" S-Form-
Fields="Name Address" S-Form-DBFields="Name Address" U-ASP-Include-
Url="../../../_fpclass/fpdbform.inc" startspan U-Database-
URL="../../../fpdb/database1.mdb" S-Builtin-Fields="REMOTE_HOST
HTTP_USER_AGENT Timestamp REMOTE_USER" S-Builtin-
DBFields="Remote_computer_name Browser_type Timestamp User_name" --
<input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--#include
file="../../../_fpclass/fpdbform.inc"--><!--webbot bot="SaveDatabase"
endspan i-checksum="52631" -->

<p><b>Name</b><br>
&nbsp;<!--webbot bot="Validation" s-display-name="Name" s-data-
type="String" b-value-required="False" i-maximum-length="255" --
<input type="TEXT" name="Name" size="64" value=""
maxlength="255"><br>
</p>
<p><b>Address</b><br>
&nbsp;<!--webbot bot="Validation" s-display-name="Address" s-data-
type="Integer" s-number-separators="," i-maximum-length="5" --
<textarea rows="10" name="Address" cols="5"></textarea><br>
</p>


<p><input type="submit" value=" OK "><input type="reset" value="
Reset "></p>

</form>

</body>

</html>


*****************************CODE WITH UPLOAD BUTTON ADDED doesn't
work
<%
' FP_ASP ASP Automatically generated by a FrontPage Component. Do not
Edit.

On Error Resume Next
Session("FP_OldCodePage") = Session.CodePage
Session("FP_OldLCID") = Session.LCID
Session.CodePage = 1252
Err.Clear

strErrorUrl = ""

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("VTI-GROUP") = "0" Then
Err.Clear

Set fp_conn = Server.CreateObject("ADODB.Connection")
FP_DumpError strErrorUrl, "Cannot create connection"

Set fp_rs = Server.CreateObject("ADODB.Recordset")
FP_DumpError strErrorUrl, "Cannot create record set"

fp_conn.Open Application("database1_ConnectionString")
FP_DumpError strErrorUrl, "Cannot open database"

fp_rs.Open "Results", fp_conn, 1, 3, 2 ' adOpenKeySet,
adLockOptimistic, adCmdTable
FP_DumpError strErrorUrl, "Cannot open record set"

fp_rs.AddNew
FP_DumpError strErrorUrl, "Cannot add new record set to the database"
Dim arFormFields0(3)
Dim arFormDBFields0(3)
Dim arFormValues0(3)

arFormFields0(0) = "Name"
arFormDBFields0(0) = "Name"
arFormValues0(0) = Request("Name")
arFormFields0(1) = "F1"
arFormDBFields0(1) = "F1"
arFormValues0(1) = Request("F1")
arFormFields0(2) = "Address"
arFormDBFields0(2) = "Address"
arFormValues0(2) = Request("Address")

FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0

If Request.ServerVariables("HTTP_USER_AGENT") <> "" Then
FP_SaveFieldToDB fp_rs, Request.ServerVariables("HTTP_USER_AGENT"),
"Browser_type"
End If
If Request.ServerVariables("REMOTE_HOST") <> "" Then
FP_SaveFieldToDB fp_rs, Request.ServerVariables("REMOTE_HOST"),
"Remote_computer_name"
End If
FP_SaveFieldToDB fp_rs, Now, "Timestamp"
If Request.ServerVariables("REMOTE_USER") <> "" Then
FP_SaveFieldToDB fp_rs, Request.ServerVariables("REMOTE_USER"),
"User_name"
End If

fp_rs.Update
FP_DumpError strErrorUrl, "Cannot update the database"

fp_rs.Close
fp_conn.Close

FP_FormConfirmation "text/html; charset=windows-1252",_
"Form Confirmation",_
"Thank you for submitting the following information:",_
"submission_form.asp",_
"Return to the form."

End If
End If

Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")

%>
<% Response.Buffer = True %>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>Results -- New</title>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

<body bgcolor="#FFFFFF">

<table width="100%" align=left>
<tr>
<td width="50%">
<b><font size=+3 color="#000080"> Submission Form </font></b>
</td>
<td width="50%" align=right>
<table>
<tr>
<td>
<a href="../results_page.asp" target="_top">Results Page</a> |
Submission Form

</td>
</tr>
</table>
</td>
</tr>
</table>


<p>
<br clear="all">
<hr>
<p>

<form METHOD="POST" action="--WEBBOT-SELF--" onsubmit="return
FrontPage_Form1_Validator(this)" language="JavaScript"
name="FrontPage_Form1" enctype="multipart/form-data">

<!--webbot bot="SaveDatabase" SuggestedExt="asp" S-
DataConnection="database1" S-RecordSource="Results" S-Form-
Fields="Name F1 Address" S-Form-DBFields="Name F1 Address" U-ASP-
Include-Url="../../../_fpclass/fpdbform.inc" startspan S-
Destination="Picupload/" S-Category S-Assignedto S-ReviewStatus B-
Process-MetaInfo="FALSE" U-Database-URL="../../../fpdb/database1.mdb"
S-Builtin-Fields="HTTP_USER_AGENT REMOTE_HOST Timestamp REMOTE_USER" S-
Builtin-DBFields="Browser_type Remote_computer_name Timestamp
User_name" --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--
#include file="../../../_fpclass/fpdbform.inc"--><!--webbot
bot="SaveDatabase" endspan i-checksum="52631" -->

<p><b>Name</b><br>
&nbsp;<!--webbot bot="Validation" s-display-name="Name" s-data-
type="String" b-value-required="False" i-maximum-length="255" --
<input type="TEXT" name="Name" size="64" value=""
maxlength="255"><br>
</p>
<p><b>Address</b><br>
&nbsp;<!--webbot bot="Validation" s-display-name="Address" s-data-
type="Integer" s-number-separators="," i-maximum-length="5" --
<textarea rows="10" name="Address" cols="5"></textarea></p>
<p><input type="file" name="F1" size="20"><br>
</p>


<p><input type="submit" value=" OK "><input type="reset" value="
Reset "></p>

</form>

</body>

</html>
 
M

Mark Fitzpatrick

Unfortunately, as far as I can remember, you're not going to get this to
work. File upload doesn't work like other types of form inputs in that it
requires a different handler on the backend to retrieve the data. The FP
upload control is part of the FP server extensions and cannot communicate
with the ASP functionality that provides the save to database functionality.
If you need to save the file to a database, you'll need to find out if your
host has other options, such as a classic ASP file upload control, which
would enable you to programatically add it by making some tweaks to the code
that FP generates. You'd need to write a little bit yourself, but it's not
terribly hard.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression
 
D

dodger741

Unfortunately, as far as I can remember, you're not going to get this to
work. File upload doesn't work like other types of form inputs in that it
requires a different handler on the backend to retrieve the data. The FP
upload control is part of the FP server extensions and cannot communicate
with the ASP functionality that provides the save to database functionality.
If you need to save the file to a database, you'll need to find out if your
host has other options, such as a classic ASP file upload control, which
would enable you to programatically add it by making some tweaks to the code
that FP generates. You'd need to write a little bit yourself, but it's not
terribly hard.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression















































...

read more »

Mark: Thanks for the effort. I talked to the hosting site support
and they said the really didn't know a way to do this. They didn't
seem to have a difinitive answer yes or no but couldn't help me saying
they can't debug my scripts. Based upon this I am taking a different
approach to my problem. I do appreciate your comments.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top