kessa
06-12-2006, 05:22 AM
Hi All,
I currently have an image upload facility on my site which uses Pure ASP upload 2.1.6 which, at the moment, only allows the uploading of images.
What I would like to do is allow a caption to be added for each image - but for some reason I can't seem to get the following script to update the database.
If (CStr(Request.QueryString("GP_upload")) <> "") Then
strsql = "UPDATE ads SET "
strsql = strsql & " caption1 = '" & padQuotes(trim(cstr(request("caption1"))))& "',"
strsql = strsql & " caption2 = '" & padQuotes(trim(cstr(request("caption2"))))& "',"
strsql = strsql & " caption3 = '" & padQuotes(trim(cstr(request("caption3"))))& "',"
strsql = strsql & " caption4 = '" & padQuotes(trim(cstr(request("caption4"))))& "',"
strsql = strsql & " caption5 = '" & padQuotes(trim(cstr(request("caption5"))))& "',"
strsql = strsql & " caption6 = '" & padQuotes(trim(cstr(request("caption6"))))& "',"
strsql = strsql & " caption7 = '" & padQuotes(trim(cstr(request("caption7"))))& "',"
strsql = strsql & " caption8 = '" & padQuotes(trim(cstr(request("caption8"))))& "',"
strsql = strsql & " caption9 = '" & padQuotes(trim(cstr(request("caption9"))))& "',"
strsql = strsql & " caption10 = '" & padQuotes(trim(cstr(request("caption10"))))& "',"
strsql = strsql & " lastupdated = '" &date&" "& time& "',"
strsql = strsql & " step5comp=1 "
strsql = strsql & " WHERE ownersidx =" & session("ownersidx") & " AND adsidx=" & request("propertyidx")
objconn.Execute(strsql)
end if
It seems to be a problem with getting the details from the form because if I enter a value directly into the update:
For example:
strsql = strsql & " caption1 = 'test',"
.... it works fine
I've also tried changing:
If (CStr(Request.QueryString("GP_upload")) <> "") Then
to ...
If (CStr(UploadFormRequest("MM_update")) = "form1" And CStr(UploadFormRequest("MM_recordId")) <> "") Then
... and to ...
if request.form("Submit")="Upload images" then
..but neither worked.
Does anyone know what may be going wrong here as I've not encountered this problem before.
The code for the form itself is:
<form action="<%=MM_editAction%>" method="post" enctype="multipart/form-data" name="form1" onSubmit="checkFileUpload(this,'GIF,JPG,JPEG,BMP',false,150,200,200,600,600,'','');showProgressWindow('upload. htm',400,150);return document.MM_returnValue" id="form">
<% for icount = 1 to var_max_photo %>
<fieldset class="adminupload">
<legend>Photo <%= (icount) %></legend>
<% if rs2("photo"&icount)>"" then %>
<img src="photos/<%= rs2("photo"&icount)%>" alt="" class="thumbnail" />
<% else %>
<img src="../../images/nophoto.gif" class="thumbnail" alt="" />
<% end if %>
<label for="photo<%= (icount) %>"><span>Select File </span></label>
<input name="photo<%= (icount) %>" type="file" id="photo<%= (icount) %>" onChange="checkOneFileUpload(this,'GIF,JPG,JPEG,BMP',false,250,200,200,600,600,'','')" /><br />
<label for="caption<%= (icount) %>"><span>Caption</span></label>
<input name="caption<%= (icount) %>" type="text" id="caption<%= (icount) %>" size="34" maxlength="37" value="<%= Recordset1.Fields.Item("caption"&icount).Value %>" />
<br />
</fieldset>
<% next %>
<p align="center">
<input name="Submit" type="submit" value="Upload images" />
</p>
<input type="hidden" name="MM_update" id="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%= Recordset1.Fields.Item("propertyidx").Value %>" />
<input type="hidden" name="propertyidx" id="propertyidx" value="<%= request("propertyidx") %>" />
</form>
Thanks
Kessa
I currently have an image upload facility on my site which uses Pure ASP upload 2.1.6 which, at the moment, only allows the uploading of images.
What I would like to do is allow a caption to be added for each image - but for some reason I can't seem to get the following script to update the database.
If (CStr(Request.QueryString("GP_upload")) <> "") Then
strsql = "UPDATE ads SET "
strsql = strsql & " caption1 = '" & padQuotes(trim(cstr(request("caption1"))))& "',"
strsql = strsql & " caption2 = '" & padQuotes(trim(cstr(request("caption2"))))& "',"
strsql = strsql & " caption3 = '" & padQuotes(trim(cstr(request("caption3"))))& "',"
strsql = strsql & " caption4 = '" & padQuotes(trim(cstr(request("caption4"))))& "',"
strsql = strsql & " caption5 = '" & padQuotes(trim(cstr(request("caption5"))))& "',"
strsql = strsql & " caption6 = '" & padQuotes(trim(cstr(request("caption6"))))& "',"
strsql = strsql & " caption7 = '" & padQuotes(trim(cstr(request("caption7"))))& "',"
strsql = strsql & " caption8 = '" & padQuotes(trim(cstr(request("caption8"))))& "',"
strsql = strsql & " caption9 = '" & padQuotes(trim(cstr(request("caption9"))))& "',"
strsql = strsql & " caption10 = '" & padQuotes(trim(cstr(request("caption10"))))& "',"
strsql = strsql & " lastupdated = '" &date&" "& time& "',"
strsql = strsql & " step5comp=1 "
strsql = strsql & " WHERE ownersidx =" & session("ownersidx") & " AND adsidx=" & request("propertyidx")
objconn.Execute(strsql)
end if
It seems to be a problem with getting the details from the form because if I enter a value directly into the update:
For example:
strsql = strsql & " caption1 = 'test',"
.... it works fine
I've also tried changing:
If (CStr(Request.QueryString("GP_upload")) <> "") Then
to ...
If (CStr(UploadFormRequest("MM_update")) = "form1" And CStr(UploadFormRequest("MM_recordId")) <> "") Then
... and to ...
if request.form("Submit")="Upload images" then
..but neither worked.
Does anyone know what may be going wrong here as I've not encountered this problem before.
The code for the form itself is:
<form action="<%=MM_editAction%>" method="post" enctype="multipart/form-data" name="form1" onSubmit="checkFileUpload(this,'GIF,JPG,JPEG,BMP',false,150,200,200,600,600,'','');showProgressWindow('upload. htm',400,150);return document.MM_returnValue" id="form">
<% for icount = 1 to var_max_photo %>
<fieldset class="adminupload">
<legend>Photo <%= (icount) %></legend>
<% if rs2("photo"&icount)>"" then %>
<img src="photos/<%= rs2("photo"&icount)%>" alt="" class="thumbnail" />
<% else %>
<img src="../../images/nophoto.gif" class="thumbnail" alt="" />
<% end if %>
<label for="photo<%= (icount) %>"><span>Select File </span></label>
<input name="photo<%= (icount) %>" type="file" id="photo<%= (icount) %>" onChange="checkOneFileUpload(this,'GIF,JPG,JPEG,BMP',false,250,200,200,600,600,'','')" /><br />
<label for="caption<%= (icount) %>"><span>Caption</span></label>
<input name="caption<%= (icount) %>" type="text" id="caption<%= (icount) %>" size="34" maxlength="37" value="<%= Recordset1.Fields.Item("caption"&icount).Value %>" />
<br />
</fieldset>
<% next %>
<p align="center">
<input name="Submit" type="submit" value="Upload images" />
</p>
<input type="hidden" name="MM_update" id="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%= Recordset1.Fields.Item("propertyidx").Value %>" />
<input type="hidden" name="propertyidx" id="propertyidx" value="<%= request("propertyidx") %>" />
</form>
Thanks
Kessa