Foros del Web » Programando para Internet » ASP Clásico »

Problema al Subir PDF

Estas en el tema de Problema al Subir PDF en el foro de ASP Clásico en Foros del Web. buenas tengo un problema, y no se cual es ya que esta rutina funciona ala perfección pero por alguna razón no puedo subir archivos en ...
  #1 (permalink)  
Antiguo 27/05/2009, 09:30
Avatar de Esfinge02  
Fecha de Ingreso: septiembre-2008
Ubicación: Cd. Victoria Tam
Mensajes: 162
Antigüedad: 16 años, 7 meses
Puntos: 2
Pregunta Problema al Subir PDF

buenas tengo un problema, y no se cual es ya que esta rutina funciona ala perfección pero por alguna razón no puedo subir archivos en PDF....



Código:

<%response.buffer=true
Func = Request("Func")
if isempty(Func) Then
Func = 1
End if
Select Case Func
Case 1
%>

<form enctype="multipart/form-data" action="ventanillaunicadoc.asp?func=2&idDoc=<%=idDOc%>" method="POST" id="form1" name="form1"> 
                <table align="center">
                <tr> 
                <td><font color="#330066" size="2">Pulsa en el botón examinar y elige el archivo 
                de tu ordenador.</font></td>
                </tr>
                <tr> 
                <td><font color="#330066" size="2">Luego pulsa el botón subir.</font></td>
                </tr>
                <tr> 
                <td><StrONG><font color="#330066" size="2">Nombre del archivo...</font></StrONG></td>
                </tr>
                <tr> 
                <td> <font size="2"> 
                <INPUT NAME=File1 SIZE=30 TYPE=file>
                <br />
                </font></td>
                </tr>
                <tr> 
                <td align=left> 
                <INPUT type="submit" value="Subir">
                </td>
                </tr>
                <tr> 
                <td><font color="#330066" size="2">NOTA: Espera, recibirás una notificación 
                cuando el archivo haya sido subido</font><font size="2">.</font></td>
                </tr>
                </table>
</form>
<%
Case 2
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
'Creates a raw data file for with all da
' ta sent. Uncomment for debuging. 
'Set fso = CreateObject("Scripting.FileSystemObject")
'Set f = fso.OpenTextFile(server.mappath(".") & "\raw.txt", ForWriting, true)
'f.Write strDataWhole
'set f = nothing
'set fso = nothing
'get the boundry indicator
strBoundry = Request.ServerVariables ("HTTP_CONTENT_TYPE")
lngBoundryPos = instr(1,strBoundry,"boundary=") + 8 
strBoundry = "--" & right(strBoundry,len(strBoundry)-lngBoundryPos)
'Get first file boundry positions.
lngCurrentBegin = instr(1,strDataWhole,strBoundry)
lngCurrentEnd = instr(lngCurrentBegin + 1,strDataWhole,strBoundry) - 1
Do While lngCurrentEnd > 0
'Get the data between current boundry an
' d remove it from the whole.
strData = mid(strDataWhole,lngCurrentBegin, lngCurrentEnd - lngCurrentBegin)
strDataWhole = replace(strDataWhole,strData,"")

'Get the full path of the current file.
lngBeginFileName = instr(1,strdata,"filename=") + 10
lngEndFileName = instr(lngBeginFileName,strData,chr(34)) 
'Make sure they selected at least one fi
' le. 
if lngBeginFileName = lngEndFileName and lngNumberUploaded = 0 Then

Response.Write "<H2> Ha ocurrido el siguiente error.</H2>"
Response.Write "Debes elegir un archivo para subir"
Response.Write "<br /><br />Pulsa el botón volver, realiza la corrección."
Response.Write "<br /><br /><INPUT type='button' onclick='history.go(-1)' value='<< Volver' id='button'1 name='button'1>"
Response.End 
End if
'There could be one or more empty file b
' oxes. 
if lngBeginFileName <> lngEndFileName Then
strFilename = mid(strData,lngBeginFileName,lngEndFileName - lngBeginFileName)
'Creates a raw data file with data betwe
' en current boundrys. Uncomment for debug
' ing. 
'Set fso = CreateObject("Scripting.FileSystemObject")
'Set f = fso.OpenTextFile(server.mappath(".") & "\raw_" & lngNumberUploaded & ".txt", ForWriting, true)
'f.Write strData
'set f = nothing
'set fso = nothing

'Loose the path information and keep jus
' t the file name. 
tmpLng = instr(1,strFilename,"\")
Do While tmpLng > 0
PrevPos = tmpLng
tmpLng = instr(PrevPos + 1,strFilename,"\")
Loop

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

'Get the begining position of the file d
' ata sent.
'if the file type is registered with the
' browser then there will be a Content-Typ
' e
lngCT = instr(1,strData,"Content-Type:")

if lngCT > 0 Then
lngBeginPos = instr(lngCT,strData,chr(13) & chr(10)) + 4
Else
lngBeginPos = lngEndFileName
End if
'Get the ending position of the file dat
' a sent.
lngEndPos = len(strData) 

'Calculate the file size. 
lngDataLenth = lngEndPos - lngBeginPos
'Get the file data 
strFileData = mid(strData,lngBeginPos,lngDataLenth)
'Create the file. 

'response.Write (server.mappath("\Ambiental\upload\"&idDoc&""))
'response.end

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(server.mappath("\Ambiental\upload\"&idDoc&"") &_
FileName, 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
loop


Response.Write "Archivo subido"
Response.Write lngNumberUploaded & " archivo ya está en el servidor.<br />"
Response.Write "<br /><br /><INPUT type='button' onclick='document.location=" & chr(34) & "ventanillaunicaDestinatario.asp?idDoc="&idDoc&"" & chr(34) & "' value='<< Volver' id='button'1 name='button'1>" 
End Select 
%>
__________________
La ignorancia es una bendición o un privilegio, yo lo siento programadores

Última edición por Esfinge02; 27/05/2009 a las 11:00
  #2 (permalink)  
Antiguo 27/05/2009, 12:05
Avatar de Esfinge02  
Fecha de Ingreso: septiembre-2008
Ubicación: Cd. Victoria Tam
Mensajes: 162
Antigüedad: 16 años, 7 meses
Puntos: 2
Respuesta: Problema al Subir PDF

una duda mas si alguien sabe como renombrar los archivos se los agrade seria, ya que de la forma que esta actualmente, solo agrega la variable al nombre que tiene el archivo.
__________________
La ignorancia es una bendición o un privilegio, yo lo siento programadores
  #3 (permalink)  
Antiguo 29/05/2009, 18:57
Avatar de Esfinge02  
Fecha de Ingreso: septiembre-2008
Ubicación: Cd. Victoria Tam
Mensajes: 162
Antigüedad: 16 años, 7 meses
Puntos: 2
Respuesta: Problema al Subir PDF

buenas al parecer la instrucción esta bien el único problema es el tamaño del archivo, recuerdo que esta rutina sirve para subir cualquier tipo de archivo,

ahora lo único que quiero es que alguien me diga como cambiarle el nombre al archivo que estoy subiendo.........
__________________
La ignorancia es una bendición o un privilegio, yo lo siento programadores
  #4 (permalink)  
Antiguo 31/05/2009, 15:27
Avatar de Valery-Net  
Fecha de Ingreso: agosto-2008
Mensajes: 694
Antigüedad: 16 años, 8 meses
Puntos: 12
Respuesta: Problema al Subir PDF

Puedes renombarlo así:

Cita:
set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFile "c:\archivo.txt", "c:\nuevonombre.txt"
set fso = Nothing

Última edición por Valery-Net; 31/05/2009 a las 15:36
  #5 (permalink)  
Antiguo 01/06/2009, 12:51
Avatar de Esfinge02  
Fecha de Ingreso: septiembre-2008
Ubicación: Cd. Victoria Tam
Mensajes: 162
Antigüedad: 16 años, 7 meses
Puntos: 2
Respuesta: Problema al Subir PDF

oko gracias lo probare y te digo si me funciona gracias........
__________________
La ignorancia es una bendición o un privilegio, yo lo siento programadores
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:27.