Forums
This topic is locked
Urgent help required with .asp pure image upload
Posted 03 Jul 2006 15:22:11
1
has voted
03 Jul 2006 15:22:11 Kessa Thomas posted:
Hi All,I've been having a few problems with .asp pure image upload 2.1.6 and although I've managed to find a way around most of them one of them still has me stumped - any ideas regarding the following would be really appreciated.
A little while ago I tried to add the ability for users to add a caption for each image. I did this by adding the following code (in red) to the .asp on the upload page (I've left some of the other surrounding code in the following so that you can see where my code sits):
<pre id=code><font face=courier size=2 id=code> ' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And UploadQueryString <> "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And UploadQueryString <> "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & UploadQueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & UploadQueryString
End If
End If
End If
%>
<%
' *** Update Record: (Modified for File Upload) construct a sql update statement and execute it
If (CStr(UploadFormRequest("MM_update") <> "" And CStr(UploadFormRequest("MM_recordId") <> "" Then
<font color=red>
'KT added code (7th June 2006) - save comments and update the time last edited
' have to use UploadFormRequest in order to address upload binary read issue
strsql = "UPDATE properties SET "
strsql = strsql & " caption1 = '" & padQuotes(trim(cstr(UploadFormRequest("caption1"))) & "',"
strsql = strsql & " caption2 = '" & padQuotes(trim(cstr(UploadFormRequest("caption2"))) & "',"
strsql = strsql & " caption3 = '" & padQuotes(trim(cstr(UploadFormRequest("caption3"))) & "',"
strsql = strsql & " caption4 = '" & padQuotes(trim(cstr(UploadFormRequest("caption4"))) & "',"
strsql = strsql & " caption5 = '" & padQuotes(trim(cstr(UploadFormRequest("caption5"))) & "',"
strsql = strsql & " caption6 = '" & padQuotes(trim(cstr(UploadFormRequest("caption6"))) & "',"
strsql = strsql & " caption7 = '" & padQuotes(trim(cstr(UploadFormRequest("caption7"))) & "',"
strsql = strsql & " caption8 = '" & padQuotes(trim(cstr(UploadFormRequest("caption8"))) & "',"
strsql = strsql & " caption9 = '" & padQuotes(trim(cstr(UploadFormRequest("caption9"))) & "',"
strsql = strsql & " caption10 = '" & padQuotes(trim(cstr(UploadFormRequest("caption10"))) & "',"
strsql = strsql & " lastupdated = '" &date&" "& time & "',"
strsql = strsql & " step5comp=1 "
strsql = strsql & " WHERE ownersidx =" & session("ownersidx" & " AND propertyidx=" & UploadFormRequest("propertyidx"
objconn.Execute(strsql)
</font id=red>
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),","
MM_delim = MM_typeArray(0)
If (MM_delim = "none" Then MM_delim = ""
</font id=code></pre id=code>
However, although the captions can now been saved, I get a problem when the user tried to update a caption, but not an image. The problem seems to resolve around the following function (in the incpureupload.asp file):
<pre id=code><font face=courier size=2 id=code>
'Fix for the update record
Function FixFieldsForUpload(GP_fieldsStr, GP_columnsStr)
Dim GP_counter, GP_Fields, GP_Columns, GP_FieldName, GP_FieldValue, GP_CurFileName, GP_CurContentType
GP_Fields = Split(GP_fieldsStr, "|"
GP_Columns = Split(GP_columnsStr, "|"
GP_fieldsStr = ""
' Get the form values
For GP_counter = LBound(GP_Fields) To UBound(GP_Fields) Step 2
GP_FieldName = LCase(GP_Fields(GP_counter))
GP_FieldValue = GP_Fields(GP_counter+1)
if UploadRequest.Exists(GP_FieldName) then
GP_CurFileName = UploadRequest.Item(GP_FieldName).Item("FileName"
GP_CurContentType = UploadRequest.Item(GP_FieldName).Item("ContentType"
else
GP_CurFileName = ""
GP_CurContentType = ""
end if
if (GP_CurFileName = "" and GP_CurContentType = "" or (GP_CurFileName <> "" and GP_CurContentType <> "" then
GP_fieldsStr = GP_fieldsStr & GP_FieldName & "|" & GP_FieldValue & "|"
end if
Next
if GP_fieldsStr <> "" then
GP_fieldsStr = Mid(GP_fieldsStr,1,Len(GP_fieldsStr)-1)
else
Response.Write "<b>An error has occured during record update!</b><br/><br/>"
Response.Write "There are no fields to update ...<br/>"
Response.Write "If you are trying to update the caption, then please also remember to update the image.<br/>"
Response.Write "Please correct and <a href=""javascript:history.back(1)"">try again</a>"
Response.End
end if
FixFieldsForUpload = GP_fieldsStr
End Function
</font id=code></pre id=code>
I've tried changing:
<b>if GP_fieldsStr <> "" then
GP_fieldsStr = Mid(GP_fieldsStr,1,Len(GP_fieldsStr)-1)
else </b>
....to....
<b>if GP_fieldsStr <> "" <font color=red>
AND UploadFormRequest("caption1" <>""
AND UploadFormRequest("caption2" <>""
AND UploadFormRequest("caption3" <>""
AND UploadFormRequest("caption4" <>""
AND UploadFormRequest("caption5" <>""
AND UploadFormRequest("caption6" <>""
AND UploadFormRequest("caption7" <>""
AND UploadFormRequest("caption8" <>""
AND UploadFormRequest("caption9" <>""
AND UploadFormRequest("caption10" <>""</font id=red> then
GP_fieldsStr = Mid(GP_fieldsStr,1,Len(GP_fieldsStr)-1)
else </b>
... but still no joy (I've asl tried using "UploadRequest"
Any ideas?
Thanks
Kessa
Replies
Replied 04 Jul 2006 16:04:02
04 Jul 2006 16:04:02 Kessa Thomas replied:
Hi All,
<b>George / Patrick</b> - have you got any ideas about how to fix this? I'm really running out of time for this project.
If anyone else may have any ideas then please feel free to dive in!
Cheers
Kessa
<b>George / Patrick</b> - have you got any ideas about how to fix this? I'm really running out of time for this project.
If anyone else may have any ideas then please feel free to dive in!
Cheers
Kessa
Replied 10 Jul 2006 18:35:45
10 Jul 2006 18:35:45 Patrick Woldberg replied:
The FixFieldsForUpload function is to manipulate the original update behavior of dreamweaver, with the changes you made in the update it won't do anything. Is it a second table where the properties are stored and do you use the default update behavior for the filefields? Perhaps you could e-mail me the full ASP to
so I can see how you trying to do it.
--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Administrator at DMXzone.com, FLzone.net, FWzone.net and DNzone.com
--------------------------------------------------
--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Administrator at DMXzone.com, FLzone.net, FWzone.net and DNzone.com
--------------------------------------------------
Replied 13 Jul 2006 13:05:37
13 Jul 2006 13:05:37 Kessa Thomas replied:
Hi Patrick,
Thanks - but I've kinda got it sorted now - decided to take the easy route and added an "edit caption only" option which takes the user to a form just displaying the captions.
I'll see how this goes for a bit and will get back to you if I need to revert back to the single form option.
Thanks!
Kessa
Thanks - but I've kinda got it sorted now - decided to take the easy route and added an "edit caption only" option which takes the user to a form just displaying the captions.
I'll see how this goes for a bit and will get back to you if I need to revert back to the single form option.
Thanks!
Kessa