11/06/2009, 03:36
|
| | | Fecha de Ingreso: enero-2004
Mensajes: 425
Antigüedad: 21 años Puntos: 1 | |
Respuesta: cambio de imagen con src
Código:
<%@LANGUAGE="VBSCRIPT"%>
<%response.buffer=true
Func = Request("Func")
if isempty(Func) Then
Func = 1
End if
Select Case Func
Case 1
%><TITLE>Subir Imagenes</TITLE>
<META HTTP-EQUIV="The JavaScript Source" CONTENT = "no-cache">
<style>
.divstyle{
position:absolute;
width="0"; height:"0";
width: 24px;
}
body {
background-color: #CCCCCC;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
function showimg(form)
{
adres = form.file1.value;
index = adres.indexOf(".gif");
index = index + adres.indexOf(".pdf");
index = index + adres.indexOf(".jpg");
if (form.file1.value == "")
{alert("No se encuentra el archivo!");}
else
{if (index == -3){alert("Unknow image type");
form.width.value=0;
form.height.value=0;}
else
{
var img_obj = new Image();
img_obj = form.file1.value;
document.changing.src = img_obj;
document.changing2.src= img_obj;
document.changing.width = 273;
document.changing.height = 170;
valor = img_obj;
archivo = valor.split("\\");
nArchivo = archivo[archivo.length-1];
window.opener.colores.foto.value=form.file1.value;
window.opener.colores.foto.value=nArchivo;
window.opener.form1.changing.src= img_obj;
window.opener.form1.changing2.src= img_obj;
set();
}
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../../admin/include/style.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY vlink=#0000ff onLoad="set()">
<tr><td width="99%" align=center>
<basefont size=3>
<center>
<form ENCTYPE="multipart/form-data" ACTION="imagen.asp?func=2" METHOD=POST id=form1 name=form1>
<input name="file1" type="file" id="file1" onChange="showimg(this.form)">
<table width="290" height="180" border="1" cellpadding="0" cellspacing="0" bordercolor="#000066" bgcolor="#FFFFFF">
<tr>
<td><table width="273" height="104" border ="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#FFFFFF">
<tr>
<td><div align="center"><img src="../icons/lphoto.png" name="changing" width="32" height="32" align="absmiddle"> </div></td>
</tr>
</table></td>
</tr>
</table>
<INPUT type="submit" value="Subir">
</form>
<div STYLE="left:732px;top:191px" class="divstyle">
<P ><img src="/2009/images/icons/lphoto.png" name="changing2" width="32" height="32"></p>
</div>
</center>
<a name="source">
<%
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)
lngCurrentBegin = instr(1,strDataWhole,strBoundry)
lngCurrentEnd = instr(lngCurrentBegin + 1,strDataWhole,strBoundry) - 1
Do While lngCurrentEnd > 0
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
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
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
strFileData = mid(strData,lngBeginPos,lngDataLenth)
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(server.mappath("..") & "\muebles\" &_
FileName, ForWriting, True)
f.Write strFileData
Set f = nothing
Set fso = nothing
lngNumberUploaded = lngNumberUploaded + 1
End if
lngCurrentBegin = instr(1,strDataWhole,strBoundry)
lngCurrentEnd = instr(lngCurrentBegin + 1,strDataWhole,strBoundry) - 1
loop
%>
<SCRIPT>
window.close();
</script>
<%
End Select
%>
</body></html>
|