close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Image Upload

Thread began 2/19/2010 3:36 pm by fireplug41126928 | Last modified 2/23/2010 11:50 am by Jason Byrnes | 1324 views | 5 replies |

fireplug41126928

Image Upload

Is there a way, to have a file field on a update form and if there is no new image have it ignore it and not replace the file name in the database.

ie, a form that updates a profile, and i don't want to update the picture just the info. If i have the image field linked to the update line in data assist and dont have it upload a new pic then it erases the name in the file field.

Sign in to reply to this post

Jason ByrnesWebAssist

yes, on the update page, create a hidden form element. set the initial value of the hidden form element to use the value from the file column in the recordset.


In the upload file server behavior, click the lightning bolt next to default file and select the hidden form element.


this is covered in the "How to apply Digital File Pro to DataAssist Insert and Update pages" tutorial in the how to section of the DFP support page:
digital-file-pro/

Sign in to reply to this post

fireplug41126928

Ok i am now getting an error on the page.

-----------------------------------------------------------------------------

Request object error 'ASP 0208 : 80004005'

Cannot use generic Request collection

/admin/home_edit.asp, line 21

Cannot use the generic Request collection after calling BinaryRead.

-----------------------------------------------------------------------------

This is the code from the page

-----------------------------------------------------------------------------

<%
Dim rs_edit__MMColParam
rs_edit__MMColParam = "1"
If (Request("MM_EmptyValue") <> "") Then (this is line 21)
rs_edit__MMColParam = Request("MM_EmptyValue")
End If
%>
<%
Dim rs_edit
Dim rs_edit_cmd
Dim rs_edit_numRows

Set rs_edit_cmd = Server.CreateObject ("ADODB.Command")
rs_edit_cmd.ActiveConnection = MM_htusa_conn_STRING
rs_edit_cmd.CommandText = "SELECT * FROM tblPages WHERE ID = ?"
rs_edit_cmd.Prepared = true
rs_edit_cmd.Parameters.Append rs_edit_cmd.CreateParameter("param1", 5, 1, -1, rs_edit__MMColParam) ' adDouble

Set rs_edit = rs_edit_cmd.Execute
rs_edit_numRows = 0
%>
<%
WA_DFP_SetupUploadStatusStruct "WA_UploadResult1"
If(Request.ServerVariables("Request_Method") = "POST") Then
WA_DFP_UploadFile "WA_UploadResult1", "NewImage", "" & cStr(WA_DFP_UploadObj.Form("DefaultFileName")) & "", "images/", "[FileName]", "2", "[FileName]_[Increment]", "0", "true", "" & cStr((rs_edit.Fields.Item("pic1w").Value)) & "", "" & cStr((rs_edit.Fields.Item("pic1h").Value)) & ""
End If%>
<%
' WA Application Builder Update
if (Request.ServerVariables("Request_Method") = "POST") then
WA_connection = MM_htusa_conn_STRING
WA_table = "tblPages"
WA_redirectURL = "admin_home.asp"
WA_keepQueryString = false
WA_indexField = "ID"
WA_fieldNamesStr = "text1|text2|text3|pic1"
WA_fieldValuesStr = "" & cStr(WA_DFP_UploadObj.Form("TextFix1")) & "" & "|" & "" & cStr(WA_DFP_UploadObj.Form("TextFix2")) & "" & "|" & "" & cStr(WA_DFP_UploadObj.Form("TextFix3")) & "" & "|" & "" & cStr(WA_DFP_UploadStatus.Item("WA_UploadResult1").serverFileName) & ""
WA_columnTypesStr = "',none,''|',none,''|',none,''|',none,''"
WA_comparisonStr = "=|=|=|="
WA_fieldNames = Split(WA_fieldNamesStr,"|")
WA_fieldValues = Split(WA_fieldValuesStr,"|")
WA_columns = Split(WA_columnTypesStr,"|")
WA_comparisions = Split(WA_comparisonStr, "|")

WA_where_fieldValuesStr = "" & cStr((rs_edit.Fields.Item("ID").Value)) & ""
WA_where_columnTypesStr = "none,none,NULL"
WA_where_comparisonStr = "="
WA_where_fieldNames = Split(WA_indexField,"|")
WA_where_fieldValues = Split(WA_where_fieldValuesStr,"|")
WA_where_columns = Split(WA_where_columnTypesStr,"|")
WA_where_comparisions = Split(WA_where_comparisonStr, "|")


updateParamsObj = WA_AB_generateInsertParams(WA_fieldNames, WA_columns, WA_fieldValues, -1)
WhereObj = WA_AB_generateWhereClause(WA_where_fieldNames, WA_where_columns, WA_where_fieldValues, WA_where_comparisions)

set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = WA_connection
MM_editCmd.CommandText = "UPDATE " & WA_table & " SET " & updateParamsObj(3) & " WHERE " & WhereObj & ""
MM_editCmd.Execute()
MM_editCmd.ActiveConnection.Close()
if (WA_redirectURL <> "") then
if (WA_keepQueryString AND Request.QueryString <> "" AND Request.QueryString.Count > 0) then
if (inStr(WA_redirectURL,"?") > 0) then
WA_redirectURL = WA_redirectURL & "&"
else
WA_redirectURL = WA_redirectURL & "?"
end if
WA_redirectURL = WA_redirectURL & Request.QueryString
end if
Response.Redirect(WA_redirectURL)
end if
end if
%>

-----------------------------------------------------------------------------

Getting a little frusterating.

Sign in to reply to this post

Jason ByrnesWebAssist

this is a limitation to ASP when uploading a file, the generic request collection is used by the recordset.



change the fdollowing code:
If (Request("MM_EmptyValue") <> "") Then
rs_edit__MMColParam = Request("MM_EmptyValue")


to:
If (Request.QueryString("MM_EmptyValue") <> "") Then
rs_edit__MMColParam = Request.QueryString("MM_EmptyValue")

Sign in to reply to this post

fireplug41126928

Ok so that resolved the error but it is not uploading the image or saving the new file name in the database. It does update the other text fields though.

Sign in to reply to this post

Jason ByrnesWebAssist

can you send a copy of the asp page so I can see the entire code in context.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...