Link to home
Start Free TrialLog in
Avatar of elliottbenzle
elliottbenzle

asked on

trouble setting variable value

I should be able to do this by now, but I am having trouble setting the value of my variable to include the filename location. Right now it looks like this:

Dim myFile
myFile=File.Name

I want to add the text "uploads/" before the file name, becaue this is the location of the stored files. Below is what I tried but it didn't work. How do I do this?

myFile=("uploads/" & File.Name)
Avatar of elliottbenzle
elliottbenzle

ASKER

I did response.write(myFile) and I get the right value "uploads/filename.jpg" but this value refused to upload into the database. Is there a reason why the variable won't input intot he database if I add this text? or is there a different way I should go about this?

Dim myFile, myDescription, myWidth, myHeight
myFile=("uploads/" & File.Name)

set comadddetail = Server.CreateObject("ADODB.Command")
comadddetail.ActiveConnection = MM_yotshop_STRING
comadddetail.CommandText = "INSERT INTO  uploadedfiles ( filename, description, sWidth, sHeight)  VALUES ( '" & myFile & "', '" & myDescription & "', " & myWidth & ", " & myHeight & " ) "
comadddetail.CommandType = 1
comadddetail.CommandTimeout = 0
comadddetail.Prepared = true
comadddetail.Execute()
What happens if you manually assign the file name, like this:

Dim myFile, myDescription, myWidth, myHeight
myFile = "uploads/filename.jpg"

set comadddetail = Server.CreateObject("ADODB.Command")
comadddetail.ActiveConnection = MM_yotshop_STRING
comadddetail.CommandText = "INSERT INTO  uploadedfiles ( filename, description, sWidth, sHeight)  VALUES ( '" & myFile & "', '" & myDescription & "', " & myWidth & ", " & myHeight & " ) "
comadddetail.CommandType = 1
comadddetail.CommandTimeout = 0
comadddetail.Prepared = true
comadddetail.Execute()
Try:

  myFile= "uploads/" & File.Name
Rouchie that worked great. Would you mind explaining why, just so I don't make the same mistake again in the future?
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