Link to home
Start Free TrialLog in
Avatar of elliottbenzle
elliottbenzle

asked on

Upload image width and height into a database

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

and

, " & 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?

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#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
      Uploader.Upload
      If Err Then
            Response.Write err.description
            Response.End()
      End If

Dim myFile, myDescription, myWidth, myHeight
myFile=File.Name
myDescription=Uploader.Form("description")
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
comadddetail.Execute()


      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
%>
ASKER CERTIFIED SOLUTION
Avatar of Rouchie
Rouchie
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial