troubleshooting Question

Upload image width and height into a database

Avatar of elliottbenzle
elliottbenzle asked on
Adobe Dreamweaver
2 Comments2 Solutions268 ViewsLast Modified:
I'm trying to upload an image with it's width and height. Everything works fine until I add this:

,width, height                                               to INSERT INTO


, " & myWidth & ", " & myHeight & "               to VALUES ()

into the SQL. After adding this the image will upload but none of the information is inserted into the database. In the database the fields are named "width" and "height" and they are both set to datatype=number, fieldsize=single, decimal places=auto. I'm using an uplaod script called ASPUploader. Can someone tke a look at the code below and tell me why this is not working?

<!--#include file="Connections/yotshop.asp" -->
<!--#include file="Upload.asp" -->
  dim Uploader, File
  set Uploader = GetASPUploader
  Set File = Uploader.AddFile("file")

      File.ValidFileTypes = "jpg,bmp,gif"
      File.Maxsize = 1024*1024
      File.Overwrite = false
      Uploader.Destination = "C:\Inetpub\wwwroot\yotshop\uploads"
      Server.ScriptTimeout = 900
      On Error Resume Next
      If Err Then
            Response.Write err.description
      End If

Dim myFile, myDescription, myWidth, myHeight
Call sImageProperties(Uploader.Destination & myFile)

set comadddetail = Server.CreateObject("ADODB.Command")
comadddetail.ActiveConnection = MM_yotshop_STRING

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< When I change this SQL things are no longer inserted into the DB >>

comadddetail.CommandText = "INSERT INTO  uploadedfiles ( filename, description)  VALUES ( '" & myFile & "', '" & myDescription & "' ) "
comadddetail.CommandType = 1
comadddetail.CommandTimeout = 0
comadddetail.Prepared = true

      Set Uploader=Nothing

Sub sImageProperties(vImage)
      Dim image, fs
      Set fs=CreateObject("Scripting.FileSystemObject")
      If Not fs.fileExists(vImage) Then Exit Sub
      Set image = loadpicture(vImage)
      myWidth = Round(image.width / 26.4583)
      myHeight = Round(image.height / 26.4583)
      Set image = Nothing
      Set fs=Nothing
End Sub

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. 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