Forums
This topic is locked
Update image field return a null value
12 Jul 2003 20:43:54 Ric A posted:
I have a problem when I try to update image. If I select an image on the update page it works fine but if
I don't select any image the other fields will be update
correctly but the image field return with a null
value in the database.
There is possible if I don't select any image that
select the recordset it contains the image value and
insert it in the same image field?
I use Pure ASP UPLOAD 2.13 and Update command (Stored Procedure).
A page send value to update page called (update.asp)
Here is the code for update.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/tdsfconn.asp" -->
<!--#include file="ScriptLibrary/incPureUpload.asp" -->
<%
'*** Pure ASP File Upload 2.1.3
Dim GP_uploadAction,UploadQueryString
PureUploadSetup
If (CStr(Request.QueryString("GP_upload"


Dim pau_thePath,pau_Extensions,pau_Form,pau_Redirect,pau_storeType,pau_sizeLimit,pau_nameConflict,pau_requireUpload,pau_minWidth,pau_minHeight,pau_maxWidth,pau_maxHeight,pau_saveWidth,pau_saveHeight,pau_timeout,pau_progressBar,pau_progressWidth,pau_progressHeight
pau_thePath = """imgs"""
pau_Extensions = ""
pau_Form = "form1"
pau_Redirect = ""
pau_storeType = "file"
pau_sizeLimit = ""
pau_nameConflict = "over"
pau_requireUpload = "false"
pau_minWidth = ""
pau_minHeight = ""
pau_maxWidth = ""
pau_maxHeight = ""
pau_saveWidth = ""
pau_saveHeight = ""
pau_timeout = "600"
pau_progressBar = "showProgress.htm"
pau_progressWidth = "300"
pau_progressHeight = "100"
Dim RequestBin, UploadRequest
CheckPureUploadVersion 2.13
ProcessUpload pau_thePath,pau_Extensions,pau_Redirect,pau_storeType,pau_sizeLimit,pau_nameConflict,pau_requireUpload,pau_minWidth,pau_minHeight,pau_maxWidth,pau_maxHeight,pau_saveWidth,pau_saveHeight,pau_timeout
end if
%>
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("AlbumID"


Recordset1__MMColParam = Request.QueryString("AlbumID"

End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset"

Recordset1.ActiveConnection = MM_tdsfconn_STRING
Recordset1.Source = "SELECT * FROM tot WHERE AlbumID = " + Replace(Recordset1__MMColParam, "'", "''"

Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<% If UploadFormRequest("update"

<% If UploadFormRequest("imgs2"

<% varimg2 = Recordset1.Fields.Item("imgs"

<%
if(UploadFormRequest("album"



if(UploadFormRequest("artist"



if(UploadFormRequest("format"



if(UploadFormRequest("genre"



if(varimg2 <> ""

if(UploadFormRequest("hdnID"



%>
<%
set Command2 = Server.CreateObject("ADODB.Command"

Command2.ActiveConnection = MM_tdsfconn_STRING
Command2.CommandText = "UPDATE tot SET AlbumTitle = '" + Replace(Command2__varalb, "'", "''"






Command2.CommandType = 1
Command2.CommandTimeout = 0
Command2.Prepared = true
Function newFileSystemObject()
set newFileSystemObject=Server.CreateObject("Scripting.FileSystemObject"

End Function
Function fileExists(aFileSpec)
fileExists=newFileSystemObject.fileExists(aFileSpec)
End Function
If UploadFormRequest("imgs"


' create file scripting object
Set File = CreateObject("Scripting.FileSystemObject"

FolderPath = Server.MapPath("imgs/"

ImagePath = FolderPath & "/" & (Recordset1.Fields.Item("imgs"

' check if file exists and if true delete the file
If fileExists(ImagePath) Then
File.DeleteFile(ImagePath)
End If
End if
Command2.Execute()
%>
<% else %>
<%
if(UploadFormRequest("album"



if(UploadFormRequest("artist"



if(UploadFormRequest("format"



if(UploadFormRequest("genre"



if(UploadFormRequest("imgs2"



if(UploadFormRequest("hdnID"



%>
<%
set Command1 = Server.CreateObject("ADODB.Command"

Command1.ActiveConnection = MM_tdsfconn_STRING
Command1.CommandText = "UPDATE tot SET AlbumTitle = '" + Replace(Command1__varalb, "'", "''"






Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Function newFileSystemObject()
set newFileSystemObject=Server.CreateObject("Scripting.FileSystemObject"

End Function
Function fileExists(aFileSpec)
fileExists=newFileSystemObject.fileExists(aFileSpec)
End Function
If UploadFormRequest("imgs"


' create file scripting object
Set File = CreateObject("Scripting.FileSystemObject"

FolderPath = Server.MapPath("imgs/"

ImagePath = FolderPath & "/" & (Recordset1.Fields.Item("imgs"

' check if file exists and if true delete the file
If fileExists(ImagePath) Then
File.DeleteFile(ImagePath)
End If
End if
Command1.Execute()
%>
<% End If %>
<% End If %>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript" src="ScriptLibrary/incPureUpload.js"></script>
</head>
<body>
<form action="<%=GP_uploadAction%>" method="post" enctype="multipart/form-data" name="form1" onSubmit="checkFileUpload(this,'',false,'','','','','','','');showProgressWindow('showProgress.htm',300,100);return document.MM_returnValue">
<table width="350" border="1" align="center">
<tr>
<td width="92">AlbumID</td>
<td width="242">
<input name="hdnID" type="hidden" id="hdnID" value="<%=(Recordset1.Fields.Item("AlbumID"

</tr>
<tr>
<td>Genre</td>
<td>
<input name="genre" type="text" id="genre" value="<%=(Recordset1.Fields.Item("GenreID"

</tr>
<tr>
<td>Artist</td>
<td>
<input name="artist" type="text" id="artist" value="<%=(Recordset1.Fields.Item("ArtistName"

</tr>
<tr>
<td>Album</td>
<td>
<input name="album" type="text" id="album" value="<%=(Recordset1.Fields.Item("AlbumTitle"

</tr>
<tr>
<td>Format</td>
<td>
<input name="format" type="text" id="format" value="<%=(Recordset1.Fields.Item("FormatID"

</tr>
<tr>
<td>imgs</td>
<td>
<%
If (Recordset1.Fields.Item("imgs"

Response.Write("<tr><td nowrap class=""specialbold"">Immagine attuale</td><td><img src='"&("imgs/"



Else
Response.Write(""

End if
%>
</td>
</tr>
<tr>
<td>imgs2</td>
<td>
<input name="imgs2" type="file" id="imgs2" onChange="checkOneFileUpload(this,'',false,'','','','','','','')"></td>
</tr>
<tr>
<td> </td>
<td>
<input name="update" type="submit" id="update" value="update"></td>
</tr>
</table>
</form>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
Anyone can help me?