By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,419 Members | 1,636 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,419 IT Pros & Developers. It's quick & easy.

SA Upload SQL Database variable types (image upload and storage)

P: 12
SA Upload SQL Database variable types (image upload and storage)

I am having trouble with the SA Upload utility. The following code used to work correctly. However, I lost my database and had to rebuild. Does anyone have any suggestions on what I may have wrong. I am not sure if I built my table to store the picture id's correctly. Maybe a field type or something.

Expand|Select|Wrap|Line Numbers
  1. <form name="UpdatePropertyPicture" method="POST" action="UpdatePropertyPicture.asp"><p><strong><font size="5">Property Picture</font></strong><br>
  2.   </p>
  3. <p><font face="Times New Roman"><b>Current Property Picture for this listing:</b></font></p>
  4. <table border="0" cellpadding="0" width="100%" cols=4>
  5. <td>
  6. </td>    
  7.  
  8. <%
  9. Set rs = Server.CreateObject("ADODB.Recordset")
  10. SQL = "Select list_id, PictureName"
  11. SQL = SQL & " from tblDescr"
  12. SQL = SQL & " where list_id = " & varlistid
  13.  
  14. 'open the recordset
  15. rs.Open SQL, cn
  16. varPicture = rs("PictureName")
  17. rs.close
  18. cn.Close
  19. %>
  20.  
  21.   <tr>
  22.     <td width="1%"><input type="hidden" size="15" maxlength="15" name="txtlistid" value="<%=varlistid%>"></td>
  23.     <td width="12%" valign="top">
  24.        <%If varpicture = "" Then%>
  25.             No Picture
  26.        <%Else%>
  27.             <input type="checkbox" name="chkPropertyPicture" value="<%=varPicture%>">
  28.             <%=varPicture%>
  29.             <input TYPE="HIDDEN" Name="h<%=I%>" VALUE="<%=varPicture%>">
  30.        <%End If%>
  31.     </td>
  32.     <td width="25%" align="center">
  33.       <img src="images/Pictures/<%=varPicture%>" height="275" width="225" align="center">    </td>
  34.     <td width="25%">
  35.         <input TYPE="SUBMIT" NAME="btnUploadPicture" VALUE="Upload Property Picture">
  36.     </td>
  37.   </tr>
  38.  
  39.   <tr>
  40.     <td></td>
  41.     <td align="center"><input type="submit" value="Delete" id="btnDelete" name="btnDelete"></td>
  42.     <td></td>
  43.     <td></td>
  44.   </tr>
  45.  
  46.   </tr>
  47.     <td></td>
  48.     <td></td>
  49.     <td></td>
  50.     <td></td>
  51.   </tr>
  52.  
  53.   </tr>
  54.     <td></td>
  55.     <td></td>
  56.     <%If Session("AddUpdatePic") = "Add" Then%>
  57.         <td align="center"><input type="submit" id="bntExitAdd" value="Continue to Unit Mix" name="bntExitAdd">&nbsp;&nbsp;<input TYPE="Button" NAME="btnReload" VALUE="Reload Picture" onClick="javascript:location.reload();"></td>
  58.     <%Else%>
  59.         <td align="center"><input type="submit" id="bntExitUpdate" value="Return to Update Property" name="bntExitUpdate">&nbsp;&nbsp;<input TYPE="Button" NAME="btnReload" VALUE="Reload Picture" onClick="javascript:location.reload();"></td>
  60.     <%End If%>
  61.     <td></td>
  62.   </tr>
  63. </table>
  64.  
  65. </FORM>
And this is the response page for after the image is uploaded:

Expand|Select|Wrap|Line Numbers
  1. <%
  2. 'Instanciate SA-FileUp
  3. Set upl = Server.CreateObject("SoftArtisans.FileUp")
  4.  
  5. 'Set the default path to store uploaded files. 
  6. 'upl.Path = "d:\inetpub\wwwRoot\cartergroup\Images\Pictures"    'Use this path for WCDEV03
  7. 'upl.Path = "d:/inetpub/wwwroot/cartergroup.com/www/phase2/images/Pictures/"                'Use this path for TS
  8. upl.Path = "d:/inetpub/wwwroot/kansascitycs.atempsite.com/www/falconbuilt/uploads/"
  9. varlistid = session("listid")
  10. %>
  11.  
  12. <%If upl.IsEmpty Then %>
  13.     The file that you uploaded was empty. Most likely, you did not specify a valid
  14.     filename to your browser or you left the filename field blank. Please try again.
  15.  
  16. <%ElseIf upl.ContentDisposition <> "form-data" Then %>
  17.     Your upload did not succeed, most likely because your browser
  18.     does not support Upload via this mechanism.
  19.     <br>
  20.     For Internet Explorer Users:
  21.     <UL>
  22.         <LI>For Windows 95 or Windows NT 4.0:
  23.         <UL>
  24.             <LI><A HREF="http://www.microsoft.com/ie/">Download</A> V3.02 or later of Internet Explorer
  25.             <LI><A HREF="http://www.microsoft.com/ie/download">Download</A> the File Upload Add-on
  26.             <LI>For further information, See Knowledge Base Article <A HREF="http://www.microsoft.com/kb/articles/Q165/2/87.htm">Q165287</A>
  27.         </UL>
  28.         <LI>For Windows 3.1, WFW 3.11 (Windows 16-bit), or Windows NT 3.51:
  29.         <UL><A HREF="http://www.microsoft.com/ie/">Download</A> V3.02A or later of Internet Explorer for 16-bit Windows
  30.         </UL>
  31.     </UL>
  32.     For Netscape Users:
  33.     <UL>
  34.         <LI><A HREF="http://home.netscape.com">Download</A> a version of Netscape Navigator or Communicator of 2.x or later
  35.     </UL>
  36.     For users of other browsers:
  37.     <UL>
  38.         <LI>Your browser must support a standard called RFC 1867. Please check with your browser vendor for
  39.     support of this standard.
  40.     </UL>
  41.  
  42. <%Else %>
  43.     <P><center>Your picture has been successfully transmitted to your listing.</center></P>
  44. <% 
  45.     on error resume next
  46.  
  47.     dim strFilename
  48.     dim strExtension
  49.     dim strFilename2
  50.  
  51.     strExtension = Mid(upl.UserFilename, InstrRev(upl.UserFilename, ".") + 1)
  52.     strFilename = "pic" & trim(varlistid) & "." & lcase(strExtension)
  53.  
  54.     If strExtension = "jpg" or strExtension = "gif" Then
  55.         '--- Save file - use the listID as the filename with the extension of the original file
  56.         upl.SaveAs strfilename
  57.     Else
  58.         Err = 1
  59.     End If
  60.  
  61.     If Err <> 0 Then %>
  62.         <H1><FONT COLOR="#ff0000">An error occurred when saving the file on the server.</FONT></H1>
  63.             Possible causes include:
  64.         <UL>
  65.             <LI>An incorrect filename was specified
  66.             <LI>File permissions do not allow writing to the specified area
  67.             <LI>Your picture has an extension other than .jpg or .gif
  68.         </UL>
  69.         Please check the SA-FileUp documentation for more troubleshooting information,
  70.         or send e-mail to <A HREF="mailto:info@softartisans.com">info@softartisans.com</A>
  71.  
  72.     <%Else 
  73.         'Response.Write("Upload saved successfully to " & upl.ServerName)
  74.         Response.Write("<center>Your picture has been saved successfully.</center>")
  75.  
  76.         'Get current file extension
  77.         Set rs = Server.CreateObject("ADODB.Recordset")
  78.         SQL = "SELECT PictureName FROM tblDescr "
  79.         SQL = SQL & "WHERE list_id = " & varlistid
  80.         'open the recordset
  81.         rs.Open SQL, cn
  82.  
  83.         If not rs.EOF Then
  84.             varSavPrevPic = rs("PictureName")
  85.         Else
  86.             varSavPrevPic = ""
  87.         End If
  88.         rs.close
  89.  
  90.         If strExtension <> right(varSavPrevPic,3) Then
  91.             'strFilename2 = "d:\inetpub\wwwRoot\cartergroup\Images\Pictures\" & varSavPrevPic    'Use this path for WCDEV03
  92.             strFilename2 = "d:/inetpub/wwwroot/cartergroup.com/www/phase2/images/Pictures/" & varSavPrevPic            'Use this path for TS
  93.  
  94.             'If user uploaded a logo with a different extension - it now needs to be removed from the logos directory
  95.             Set fso = CreateObject("Scripting.FileSystemObject")
  96.             Set MyFile = fso.GetFile(strFilename2)
  97.             MyFile.Delete
  98.         End If
  99.  
  100.         Set rs = Server.CreateObject("ADODB.Recordset")
  101.         SQL = "UPDATE tblDescr "
  102.         SQL = SQL & "SET PictureName = '" & strFilename & "' "
  103.         SQL = SQL & "WHERE list_id = " & varlistid
  104.         'open the recordset
  105.         rs.Open SQL, cn
  106.         rs.close
  107.         cn.Close
  108.     End If%>
Sep 24 '08 #1
Share this Question
Share on Google+
7 Replies


ck9663
Expert 2.5K+
P: 2,878
Lots of reason. What error is showing up?

-- CK
Sep 24 '08 #2

P: 12
An error occurred when saving the file on the server.
Possible causes include:

* An incorrect filename was specified
* File permissions do not allow writing to the specified area
* Your picture has an extension other than .jpg or .gif

Please check the SA-FileUp documentation for more troubleshooting information, or send e-mail to info@softartisans.com



Information About The Uploaded File
User's filename: pic26.jpg
Size in bytes: 0
Content Type:
Content Disposition:
MIME Version:
Content Transfer Encoding:
Sep 24 '08 #3

ck9663
Expert 2.5K+
P: 2,878
Check the rights...Also check if the SP can "see" the file.

-- CK
Sep 25 '08 #4

P: 12
Check the rights...Also check if the SP can "see" the file.

-- CK
WHAT IS SP? Sorry for the dumb question.
Sep 25 '08 #5

ck9663
Expert 2.5K+
P: 2,878
your Stored Procedure

-- CK
Sep 25 '08 #6

P: 12
your Stored Procedure

-- CK
I don't exactly know how to check the SP and if it can see the file.
Sep 25 '08 #7

ck9663
Expert 2.5K+
P: 2,878
Looks like the uploading did not goes through SQL Server. Did you include the SA_FileUp file? It looks like it just save the file using the SaveFile method then updates the table accordingly. If everything seems to be working fine before and you just recreated your database from a backup, try checking the rights both in File Directory and in the db

-- CK
Sep 25 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.