Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/08/2006, 13:36
grid
 
Fecha de Ingreso: julio-2003
Ubicación: Viña del mar
Mensajes: 111
Antigüedad: 21 años, 10 meses
Puntos: 0
renombrar archivo en upload

Estoy haciendo un upload al servidor y usando http://www.freeaspupload.net, funciona bien, solo que tengo problemas para renombrar el archivo una vez arriba, solo que Scripting.FileSystemObject no lo puedo usar por razones de seguridad... :(

Pense que la alternativa es escribirlo directamente con el nombre que necesito... lo cambié directamente en la clase y funcionó

streamFile.SaveToFile path & "mi_imagen.jpg" , 2 ' :)

Sin embargo no logro pasar el valor del nombre del archivo a la clase...


'llamo a la clase y le digo donde debo guardar el archivo (uploadsDirVar)
Upload.Save(uploadsDirVar)


Public Sub Save (path)
Dim streamFile, fileItem
if Right(path, 1) <> "\" then path = path & "\"
if not uploadedYet then Upload
For Each fileItem In UploadedFiles.Items
Set streamFile = Server.CreateObject("ADODB.Stream")
streamFile.Type = 1
streamFile.Open
StreamRequest.Position=fileItem.Start
StreamRequest.CopyTo streamFile, fileItem.Length
streamFile.SaveToFile path & fileItem.FileName , 2
streamFile.close
Set streamFile = Nothing
fileItem.Path = path & fileItem.FileName
Next
End Sub

//////////////////////////////////////////////////////


Yo habia hecho esto:


my_name = "hola.jpg";

Upload.Save uploadsDirVar my_name


Public Sub Save (path,my_name)
Dim streamFile, fileItem
if Right(path, 1) <> "\" then path = path & "\"
if not uploadedYet then Upload
For Each fileItem In UploadedFiles.Items
Set streamFile = Server.CreateObject("ADODB.Stream")
streamFile.Type = 1
streamFile.Open
StreamRequest.Position=fileItem.Start
StreamRequest.CopyTo streamFile, fileItem.Length
streamFile.SaveToFile path & my_name , 2 '///// aqui cambio
streamFile.close
Set streamFile = Nothing
fileItem.Path = path & fileItem.FileName
Next
End Sub

si alguien me puede orientar, gracias