Question

Using aspjpeg to upload info into a SQL SERVER database.

Asked by: cokefour

Hi there, I've downloaded aspjpeg and I'm trying to get it to save the file to my sql server database. At the moment I have worked out how to save an image to the disk and all the resizing and thumbnail bits but I can't figure out at which point I get to save the blob to the database and what happens to the thumbnail anyway.
There are the four asp files, pick_jpeg, thumbnail, send_binary and upload_jpeg but I'm stuck.

Has anyone got working code on how to get the job done and save the image, path, dimensions etc to the database?

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-01-08 at 16:26:00ID24037132
Tags

aspjpeg

,

sql server

,

asp

,

vb

Topics

Active Server Pages (ASP)

,

Adobe Dreamweaver

,

SQL Server 2005

Participating Experts
3
Points
500
Comments
17

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. ASPJPEG + ASPUPLOAD.. Using VB!
    Hi All, I have a classic ASP page that uses ASPJPEG and ASPLOAD together .. It uploads the image directly into memory, resizes it, and then inserts it into a MS-SQL Database. I need code that will do the exact same thing, but using ASP.NET; in VB... Unfortunately, the pers...
  2. resize image using aspjpeg
    i have this image path in my database and i have aspjpeg installed in my web server <%=(Recordset1.Fields.Item("image").Value)%> how can i use aspjpeg so i will display a smaller version of my image. i really do not need to save the thumbnail if it is poss...
  3. ASPJPEG - using SQL server, a table called Product and …
    Hi all I'm using ASPUPLOAD and ASPJPEG I've been looking at http://www.aspjpeg.com/manual_03.html but what would this extract of code be please if I was using SQL server, a table called Product and I was using Count = Upload.SaveVirtual("/Images/products//thumbs/"...
  4. aspJpeg component help
    Hi Am having some real trouble getting my images manipulated. I have uploaded an image to my server, which could be any size and i need to create thumbnails to fit in various frames and i then need to access them. I need to preserve ratio and create a thumbnail to fit the...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: PanchuxPosted on 2009-01-08 at 16:41:15ID: 23331773

I would rather prefer to store its name (sometimes is not really necesary) and store the image in the disk.
As far as I know this outperforms in performance saving the file into the DB.

For thumbnails I use same name but different path so I save only one name in DB.

i.e.
img path=./img name=car.jpg
thumb Path=./img/thumbs/ name=car.jpg

Hope that helps,

Pancho

 

by: cokefourPosted on 2009-01-08 at 16:55:41ID: 23331872

Hi Panchux, thanks for that but the real question is how to get aspjpeg to do it http://www.aspjpeg.com

 

by: B_DorseyPosted on 2009-01-08 at 17:21:49ID: 23332037

ASPJpeg can open the images from the database... as far as saving them to the database I think that is the other half of their software called ASPUpload

strConnect = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("../db/aspjpeg.mdb")
Set rs = Server.CreateObject("adodb.recordset")
SQL = "select image_blob from images2 where id = " & Request("id")
rs.Open SQL, strConnect, 1, 3

Set Jpeg = Server.CreateObject("Persits.Jpeg")

' Open image directly from recordset
Jpeg.OpenBinary rs("image_blob").Value

' Resize
jpeg.Width = Request("Width")

' Set new height, preserve original aspect ratio
jpeg.Height = jpeg.OriginalHeight * jpeg.Width / jpeg.OriginalWidth

Jpeg.SendBinary

rs.Close


http://www.aspjpeg.com/manual_02.html#2_3

 

by: PanchuxPosted on 2009-01-08 at 17:39:13ID: 23332107

B_Dorsey, that code will let him get an image from the DB not saving it into the DB.
I think the code he is looking for is the one attached.

Hope it helps,

Pancho

<%
...
Set rs = Server.CreateObject("adodb.recordset")
rs.Open "images", strConnect, 1, 3
rs.AddNew
rs("image_blob").Value = Jpeg.Binary
 
rs.Update
...
%> 

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:

Select allOpen in new window

 

by: R_HarrisonPosted on 2009-01-09 at 02:23:54ID: 23334180

With image dimensions...

Set rs = Server.CreateObject("adodb.recordset")
rs.Open "images", strConnect, 1, 3
rs.AddNew
rs("image_blob").Value = Jpeg.Binary
rs("imgheight").value = Jpeg.Height
rs("imgwidth").value = Jpeg.Width
 
rs.Update
                                              
1:
2:
3:
4:
5:
6:
7:
8:

Select allOpen in new window

 

by: cokefourPosted on 2009-01-09 at 03:30:00ID: 23334505

Hi Harrison, how would that code work alongside Dreamweaver if I use their Insert or Update Record Server behaviour?

 

by: cokefourPosted on 2009-01-09 at 03:37:32ID: 23334535

What I mean is which of the asp files will I need to add this code to. Here is the link to the site with the aspjpeg pages http://support.persits.com/jpeg/pick_jpeg.asp

 

by: R_HarrisonPosted on 2009-01-09 at 04:03:42ID: 23334679

This is the code that goes nn the page that saves the image to the disk (this will then save it to the database).   You will of course need a database with the fields img_blob, imgwidth & imgheight in and you will need to setup the database connection etc...

If you are stuck, then use dreamweaver to insert a record into the database you want to use (on the page that currently saves the picture into a file - use any values you like as we only want to see the connection string).    If you then paste up the code dreamweaver produces I will be able to determine what your connection string is and provide you with fully working code that you can simply cut and paste.

 

by: cokefourPosted on 2009-01-09 at 09:02:28ID: 23337574

the first page has a form

<FORM ACTION="/admin/uploadimage_2.asp" method="post" ENCTYPE="multipart/form-data">
<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="2">
	<TR><TD BGCOLOR="#E0FFF0" ALIGN="CENTER"><FONT FACE="Arial" SIZE="2" COLOR="#000000"><B>Select an Image</B></FONT></TD></TR>
	<TR><TD BGCOLOR="#EEEEEE"><INPUT TYPE="FILE" NAME="myFile" SIZE="40"></TD></TR>
	<TR><TD BGCOLOR="#EEEEEE">&nbsp;</TD></TR>
	<TR>
	  <TD BGCOLOR="#EEEEEE"><input type="SUBMIT" value="Upload Image" /></TD>
	  </TR>
</TABLE>
</FORM>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:

Select allOpen in new window

 

by: cokefourPosted on 2009-01-09 at 09:04:51ID: 23337598

It posts to the second page I've included the form that creates thumbnails but you can ignore that bit if it gets in the way

<%
	Set Upload = Server.CreateObject("Persits.Upload")
	Upload.OverwriteFiles = False
	Upload.SetMaxSize 5000000, True
	Upload.CodePage = 65001
 
	On Error Resume Next	
	Count = Upload.Save("\\nas43ent\domains\m\metrolettings.com\user\htdocs\images\property")
 
	If Err <> 0 or Count = 0 Then
		
%>
 
<FONT SIZE="3" FACE="Arial" COLOR="#FF0000"><% If Err <> 0 Then Response.Write "An error occurred:" & Err.Description Else Response.Write "Nothing has been uploaded."%></B></FONT>
<P>
<FONT SIZE="2" FACE="Arial"><A HREF="/admin/uploadimage.asp">Try again</A>.</FONT>
 
<%		
	Else
		On Error Goto 0
		Set File = Upload.Files(1)
		If File.ImageType = "UNKNOWN" Then
			File.Delete
%>
<FONT SIZE="3" FACE="Arial" COLOR="#FF0000">This is not a valid image file.</B></FONT>
<P>
<FONT SIZE="3" FACE="Arial"><A HREF="/admin/uploadimage.asp">Try again</A>.</FONT>
<%		Else
 
			' Special handling of TIFF since AspUpload cannot extract TIFF dimensions
			if File.ImageType = "TIF" Then
				Set Tiff = Server.CreateObject("Persits.Jpeg")
				Tiff.Open File.Path
				ImageWidth = Tiff.OriginalWidth				
				ImageHeight = Tiff.OriginalHeight
				Tiff.Close
			Else
				ImageWidth = File.ImageWidth
				ImageHeight = File.ImageHeight
			End if
%>
 
<FONT SIZE="2" FACE="Arial">
<B>The following <% = File.ImageType%> image has been uploaded:</B><P>
<TABLE CELLSPACING="0" CELLPADDING="2" BORDER="1">
	<TR><TD><FONT SIZE="2" FACE="Arial"><B>Path:</B></FONT></TD>
	<TD><FONT SIZE="2" FACE="Arial"><% = Server.HTMLEncode(File.OriginalPath) %></FONT></TD></TR>
	<TR><TD><FONT SIZE="2" FACE="Arial"><B>Size:</B></FONT></TD>
	<TD><FONT SIZE="2" FACE="Arial"><% = File.Size %> bytes</FONT></TD></TR>
	<TR><TD><FONT SIZE="2" FACE="Arial"><B>Dimensions:</B></FONT></TD>
	<TD><FONT SIZE="2" FACE="Arial"><% = ImageWidth %> x <% = ImageHeight %> pixels</FONT></TD></TR>
</TABLE>
<P>
<FORM ACTION="/admin/uploadimage_3.asp" METHOD="GET">
	<INPUT TYPE="HIDDEN" NAME="Path" VALUE="<% = Server.HtmlEncode(File.Path) %>">
	<INPUT TYPE="HIDDEN" NAME="Height" VALUE="<% = ImageHeight %>">
	<INPUT TYPE="HIDDEN" NAME="Width" VALUE="<% = ImageWidth %>">
	<INPUT TYPE="HIDDEN" NAME="scale" VALUE="50">
	<INPUT TYPE="HIDDEN" NAME="NewWidth" VALUE="100">
	<INPUT TYPE="HIDDEN" NAME="NewHeight" VALUE="100">
	<INPUT TYPE="HIDDEN" NAME="ResizeOption" VALUE="1">
	<INPUT TYPE="HIDDEN" NAME="Quality" VALUE="1">
	<INPUT TYPE="HIDDEN" NAME="Sharpen" VALUE="">
	<INPUT TYPE="HIDDEN" NAME="SharpenValue" VALUE="130">
	<INPUT TYPE="HIDDEN" NAME="Rotate" VALUE="0">
	<INPUT TYPE="SUBMIT" VALUE="Continue...">	
</FORM>
<P>
<IMG SRC="/images/property/<% = Server.HtmlEncode(File.ExtractFileName) %>">
<P>
<FONT SIZE="2" FACE="Arial"><A HREF="/admin/uploadimage.asp">Upload another image</A></FONT>
 
 
 
<%
 
		End If
	End If
%>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:

Select allOpen in new window

 

by: R_HarrisonPosted on 2009-01-09 at 09:04:56ID: 23337600

The page you need to do the work on is "uploadimage_2.asp"...

 

by: cokefourPosted on 2009-01-10 at 02:19:58ID: 23343028

will I be replacing
<%
      Set Upload = Server.CreateObject("Persits.Upload")
      Upload.OverwriteFiles = False
      Upload.SetMaxSize 5000000, True
      Upload.CodePage = 65001
 
      On Error Resume Next      
      Count = Upload.Save("\\nas43ent\domains\m\metrolettings.com\user\htdocs\images\property")
 
      If Err <> 0 or Count = 0 Then
            
%>
 with this?

Set rs = Server.CreateObject("adodb.recordset")
rs.Open "images", strConnect, 1, 3
rs.AddNew
rs("image_blob").Value = Jpeg.Binary
rs("imgheight").value = Jpeg.Height
rs("imgwidth").value = Jpeg.Width
 
rs.Update

 

by: PanchuxPosted on 2009-01-10 at 04:32:44ID: 23343415

If you replace those lines you will be saving the image into the DB instead of saving it to the disk.
It's the code I passed you but adding width and height. Only save those values if needed if you don't you will only get to increase the size of the DB.

You will need to change:
 "images" with the name of the table containing your images
"strConnect" with the name of the variable containing the string connection.
"image_blob" with the name of the field which will contain the image
"imgheight" and "imgwidth" with the name of the fields which will contain the height and width of the image if needed
"Jpeg" if other name for the ASPJpeg object was used you need to change that too

Pancho

 

by: R_HarrisonPosted on 2009-01-12 at 02:04:13ID: 23352040

No only replacing the save line... the code will therefore look something like the below.   As mentioned by Panchux you will need to add your database connection and have a table called images, etc...

<%
      Set Upload = Server.CreateObject("Persits.Upload")
      Upload.OverwriteFiles = False
      Upload.SetMaxSize 5000000, True
      Upload.CodePage = 65001
 
      On Error Resume Next      
'      Count = Upload.Save("\\nas43ent\domains\m\metrolettings.com\user\htdocs\images\property")
Set rs = Server.CreateObject("adodb.recordset")
rs.Open "images", strConnect, 1, 3
rs.AddNew
rs("image_blob").Value = Jpeg.Binary
rs("imgheight").value = Jpeg.Height
rs("imgwidth").value = Jpeg.Width
rs.Update
 
'     If Err <> 0 or Count = 0 Then
            
%>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:

Select allOpen in new window

 

by: R_HarrisonPosted on 2009-01-12 at 02:05:08ID: 23352046

Ignore my last post... I missed out the whole JPEG bit...

 

by: R_HarrisonPosted on 2009-01-12 at 02:14:59ID: 23352085

Corrected code below, I also added the filename as per your original request.   All you need now is the database connection string and to ensure you have a table called "images" with the appropriate field in.

<%
	Set Upload = Server.CreateObject("Persits.Upload")
	Upload.OverwriteFiles = False
	Upload.SetMaxSize 5000000, True
	Count = Upload.Save
	Set File = Upload.Files("myFile")
 
 
	set JPEG=Server.CreateObject("Persits.Jpeg")
	JPEG.OpenBinary(File.Binary)
 
 
	/// YOUR DATABASE CONNECTION STRING GOES HERE.....
	Set rs = Server.CreateObject("adodb.recordset")
	rs.Open "images", strConnect, 1, 3
	rs.AddNew
	rs("filename").Value = File.FileName
	rs("image_blob").Value = Jpeg.Binary
	rs("imgheight").value = Jpeg.Height
	rs("imgwidth").value = Jpeg.Width
	rs.Update
          
%>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:

Select allOpen in new window

 

by: cokefourPosted on 2009-01-13 at 06:39:02ID: 31532612

Thanks for that. I was just about to go back to CS3 and the Developer toolbox!

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...