473,387 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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
7 3709
ck9663
2,878 Expert 2GB
Lots of reason. What error is showing up?

-- CK
Sep 24 '08 #2
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
2,878 Expert 2GB
Check the rights...Also check if the SP can "see" the file.

-- CK
Sep 25 '08 #4
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
2,878 Expert 2GB
your Stored Procedure

-- CK
Sep 25 '08 #6
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
2,878 Expert 2GB
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

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

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
6
by: Code4u | last post by:
I need to design data storage classes and operators for an image processing system that must support a range of basic data types of different lengths i.e. float, int, char, double. I have a...
5
by: bob garbados | last post by:
I am trying to create a database-driven photo gallery for a friend with an admin form to upload images... I can upload a file to the web server, but I want to store the image in a database and I...
3
by: Shapper | last post by:
Hello, I created a script to upload a file. To determine the file type I am using userPostedFile.ContentType. For example, for a png image I get "image/png". My questions are: 1. Where can...
5
by: Seok Bee | last post by:
Dear Experts, I currently trying to use the FileUpload control from asp.net 2.0 to upload files. The uploading of the file I would like to store it in the Access Database. Unfortunately, I've no...
0
by: SEMIH DEMIR | last post by:
Sitelerden birinde verilen yabancı kaynakli bir scriptti duzenledim yanlız birseyin içinden bir turlu cıkamadım işin aslı ilk defa persistin upload componentini kullanacam yanlız suanki haliyle...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
3
acoder
by: acoder | last post by:
How to Upload a File in Coldfusion Use the cffile tag for uploading files to the server. Note that allowing people to upload files is fraught with danger and only trusted users should be...
18
jhardman
by: jhardman | last post by:
Have you ever wanted to upload files through a form and thought, "I'd really like to use ASP, it surely has that capability, but the tutorial I used to learn ASP didn't mention how to do this."? ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.