Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/04/2008, 11:50
diegof18
 
Fecha de Ingreso: marzo-2008
Mensajes: 25
Antigüedad: 17 años, 1 mes
Puntos: 0
asp upload, me cambia el path¿¿??

hola tengo un server upload y no me tira error pero antes de hacer un upload para ver las fotos ya cargadas utiliso ../y el path de carpetas hasta la imagen

despues de hacer el upload me toma una carpeta mas abajo por asi decirlo y deberia sacarle el ../ para que me encuentre la imagen? que puede ser o como se puede solucionar?

Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'Create C:\FooBar
If Not objFSO.FolderExists(Server.MapPath("../img/proyectos/promo" & txtid)) then
objFSO.CreateFolder(Server.MapPath("../img/proyectos/promo" & txtid &""))
objFSO.CreateFolder(Server.MapPath("../img/proyectos/promo" & txtid &"/fotos"))
objFSO.CreateFolder(Server.MapPath("../img/proyectos/promo" & txtid &"/planos"))
set objFSO = nothing
End If
ForWriting = 2
adLongVarChar = 201
lngNumberUploaded = 0

'Get binary data from form
noBytes = Request.TotalBytes
binData = Request.BinaryRead (noBytes)
'convery the binary data to a string
Set RST = CreateObject("ADODB.Recordset")
LenBinary = LenB(binData)

if LenBinary > 0 Then
RST.Fields.Append "myBinary", adLongVarChar, LenBinary
RST.Open
RST.AddNew
RST("myBinary").AppendChunk BinData
RST.Update
strDataWhole = RST("myBinary")
End if
strBoundry = Request.ServerVariables ("HTTP_CONTENT_TYPE")
lngBoundryPos = instr(1,strBoundry,"boundary=") + 8
strBoundry = "--" & right(strBoundry,len(strBoundry)-lngBoundryPos)
lngCurrentBegin = instr(1,strDataWhole,strBoundry)
lngCurrentEnd = instr(lngCurrentBegin + 1,strDataWhole,strBoundry) - 1
if lngCurrentEnd > 0 then
strData = mid(strDataWhole,lngCurrentBegin, lngCurrentEnd - lngCurrentBegin)
strDataWhole = replace(strDataWhole,strData,"")

lngBeginFileName = instr(1,strdata,"filename=") + 10
lngEndFileName = instr(lngBeginFileName,strData,chr(34))
if lngBeginFileName = lngEndFileName and lngNumberUploaded = 0 Then
End if
if lngBeginFileName <> lngEndFileName Then
strFilename = mid(strData,lngBeginFileName,lngEndFileName - lngBeginFileName)

tmpLng = instr(1,strFilename,"\")
Do While tmpLng > 0
PrevPos = tmpLng
tmpLng = instr(PrevPos + 1,strFilename,"\")
Loop

FileName = right(strFilename,len(strFileName) - PrevPos)

lngCT = instr(1,strData,"Content-Type:")

if lngCT > 0 Then
lngBeginPos = instr(lngCT,strData,chr(13) & chr(10)) + 4
Else
lngBeginPos = lngEndFileName
End if
lngEndPos = len(strData)

lngDataLenth = lngEndPos - lngBeginPos
'Get the file data
strFileData = mid(strData,lngBeginPos,lngDataLenth)
'nombre del archivo y datos para la base
strSQLI="UPDATE URWT_PROMOCIONES set PRO_DIRECTORIO='../img/proyectos/promo" & txtid & "/', PRO_ULTIMA = '" & ultima + 1 &"' Where PRO_CODPRO="& txtid
Conexion.BeginTrans()
Conexion.Execute(strSQLI)
Conexion.CommitTrans()
'Crear descripcion

strSQLI2="Insert Into URWT_IMAGENES (PRO_NOMBRE, PRO_CODPRO, PRO_ID) VALUES ('foto"&ultima + 1&"', "&txtid&", "&ultima + 1&")"
Conexion.BeginTrans()
Conexion.Execute(strSQLI2)
Conexion.CommitTrans()

'Create the file.
Set fso = Server.CreateObject("Scripting.FileSystemObject")
FileN = ".jpg"
Set f = fso.OpenTextFile(Server.MapPath("../img/proyectos/promo" & txtid &"/fotos/foto")& ultima + 1 & FileN, ForWriting, True)

f.Write strFileData
Set f = nothing
Set fso = nothing
lngNumberUploaded = lngNumberUploaded + 1
End if
'Get then next boundry postitions if any
lngCurrentBegin = instr(1,strDataWhole,strBoundry)
lngCurrentEnd = instr(lngCurrentBegin + 1,strDataWhole,strBoundry) - 1
end if
'Conexion a la BD "Access"
Dim Conex
Set Conex = Server.CreateObject ("ADODB.Connection")
Conex.open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("../../../data/Urnova2.mdb")
'inserto en galeria de fotos
'strSQL="INSERT INTO URWT_PROMOCIONES (IDPropiedad,PRO_DIRECTORIO) VALUES ("& id &",'"& FileName &"')"
'Conex.BeginTrans()
'Conex.Execute(strSQL)
'Conex.CommitTrans()
promo = "La Promocion se guardo correctamente. Seleccione otra opcion para subir un archivo"
response.Redirect("imagenes2.asp?txtid="&txtid&"&f oto="&ultima + 1)