Este es el upload.asp
Código :
<%
Func = Request("Func")
if isempty(Func) Then
Func = 1
End if
Select Case Func
Case 1
%>
<style type="text/css">
<!--
.titulo {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
color: #666666;
}
.texto1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #333333;
}
input {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
}
.nota {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #CC0000;
font-weight: bold;
}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<body>
<table width="400" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#666666" bgcolor="#CCCCCC">
<tr>
<td class="titulo">
<div align="center"><%=textSelImgSub%></div>
</td>
</tr>
</table>
<form enctype="multipart/form-data" action="upload.asp?func=2" method=POST id=form1 name=form1>
<table width="400" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#999999" bgcolor="#F3F3F3">
<tr>
<td class="texto1"><%=textInfoSubImg%></td>
</tr>
<tr>
<td><strong></strong> <div align="center"><font size="2">
<input name=File1 size=30 type=file>
<br>
</font></div></td>
</tr>
<tr>
<td align=left>
<div align="center">
<input type="submit" value="<%=textBotSub%>">
</div></td>
</tr>
<tr>
<td class="nota"><%=textNotaSub%></td>
</tr>
</table>
<div align="center">
<p>
<%
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
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 and 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 file.
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 boxes.
if lngBeginFileName <> lngEndFileName Then
strFilename = mid(strData,lngBeginFileName,lngEndFileName - lngBeginFileName)
'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 data sent.
'if the file type is registered with the
' browser then there will be a Content-Type
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 data sent.
lngEndPos = len(strData)
'Calculate the file size.
lngDataLenth = lngEndPos - lngBeginPos
'Get the file data
strFileData = mid(strData,lngBeginPos,lngDataLenth)
'Create the file.
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile (Server.MapPath ("\fotos") & "\" & FileName, ForWriting, True)
Dim FileName
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
End Select
%>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="65" valign="top"><table width="390" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#999999" bgcolor="#F3F3F3">
<tr>
<td height="30" class="texto1"><%=textMensArchSub%><%=FileName%><%=textMensArchEnServi%></td>
</tr>
<tr>
<td height="30"><div align="center">
<input name="button" type="button" onClick="cierra_ventana()" value="<%=textBotCerrar%>" >
</div></td>
</tr>
</table></td>
</tr>
</table>
[color=darkred]<script language="Javascript1.2">
function cierra_ventana() {
var NomArch
NomArch="<%=FileName%>"
opener.document.armar.foto.value = "/fotos/" + NomArch;
close();
}
</script>[/color]
</div>
</BODY>
</HTML>
La funcion que hay de jabascript lo que hace es mandar la info del path y el nombre del archivo al textbox correspondiente, es eso lo que quiero cambiar porque sino para cada textbox tengo que tener uno archivo upload diferente
esto es lo que llama a la pagina upload
<input name="foto" type="text" id="foto" size="25" value='<%=idFoto%>' />
<input type="button" name="Submit" class="frmButton" value="<%=textAgregar%>" onclick="subFoto()"/>
<input name="fotoG" type="text" id="fotoG" size="25" value="<%=idFotoG%>"/>
<input type="button" name="Submit2" class="frmButton" value="<%=textAgregar%>" onclick="subFotoG()" />
<input name="fotoC" type="text" id="fotoC" size="25" value='<%=idFotoC%>' />
<input type="button" name="Submit3" class="frmButton" value="<%=textAgregar%>" onclick="subFotoC()"/>
<input name="idAVideoC" type="text" id="idAVideoC" size="25" value='<%=idAVideo%>' />
<input name="botonVideo" type="button" class="frmButton" id="botonVideo" value="<%=textAgregar%>" onclick="subVideo()"/>
y como se ve lo que cambia es el onclick, se que se puede hacer algo asi
onclick="idAVideo,path"
y algo asi en jabascript
if si es idAVideo then guardar en el path el filename