Comunidad de diseño web y desarrollo en internet online

Alguien me ayuda con javascript?

Citar            
MensajeEscrito el 16 Jul 2008 01:59 pm
Bueno la cosa es asi, estoy haciendo un formulario donde tiene varios campos para subir archivos tanto de imagenes como de audio y video.
el upload lo tengo pero lo que no quiero es hacer uno diferente para cada uno de los campos y la idea mia es:
que el javascript identifique cual es el campo o textbox que lo esta llamando y al subir el archivo coloque el nombre y la direccion en dicho campo
que identifique si es una imagen, video o audio y los guarde en el directorio que corresponde
y si es para cargar varias imagenes a la vez me ponga el resultado en el campo con las direcciones y separado por un ";".
si alguien podria ayudarme ya que de javascript no entiendo
desde ya agradezco al amigo que me tienda una mano o me pase info de donde hay algo similar para poder adaptar

Por virla

4 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 16 Jul 2008 02:16 pm
Creo que no deberías usar JavaScript para esto, al menos, no para la base de lo que pides.
Para esto, usa PHP.
Mediante PHP discernirás qué tipos de archivos se subieron, su tamaño, cuántos... etcétera... y también podrás guardar cada tipo de archivo reconocido, en los directorios que así estimes conveniente.

Toda la documentación necesaria (oficial, y en castellano) para hacerlo desde PHP, aquí.

PD:
Según te vayan apareciendo dudas... nos vas preguntando... pero hacerte el trabajo entero... sólo tras acuerdo económico...

Por El Oso Amoroso

Claber

1780 de clabLevel

6 tutoriales

 

Madrid, España, Europa, Eurasia, La Tierra, Sist.Solar, Vía Láctea, UNIVERSO

firefox
Citar            
MensajeEscrito el 16 Jul 2008 02:19 pm
estoy programando en asp por eso debo utilizar javascript

Por virla

4 de clabLevel



Genero:Masculino  

msie7
Citar            
MensajeEscrito el 16 Jul 2008 02:24 pm
Estoy seguro de que ASP puede hacer lo mismo que PHP (tendrá otros comandos... pero seguro que puede)...
Aún así, te aconsejo que olvides ASP, y te pases a PHP...

Por El Oso Amoroso

Claber

1780 de clabLevel

6 tutoriales

 

Madrid, España, Europa, Eurasia, La Tierra, Sist.Solar, Vía Láctea, UNIVERSO

firefox
Citar            
MensajeEscrito el 16 Jul 2008 02:25 pm
ok pero lo que busco es en javascript
gracias amigo

Por virla

4 de clabLevel



Genero:Masculino  

msie7
Citar            
MensajeEscrito el 16 Jul 2008 02:38 pm
Es que no se pueden subir archivos, ni guardar en carpetas desde JavaScript.

Por El Oso Amoroso

Claber

1780 de clabLevel

6 tutoriales

 

Madrid, España, Europa, Eurasia, La Tierra, Sist.Solar, Vía Láctea, UNIVERSO

firefox
Citar            
MensajeEscrito el 16 Jul 2008 02:40 pm
eso lo se amigo, lo que necesito es que jabascript identifique que textbox es al que tiene que ponerle el path/nombre_imagen.jpg para que se guarde despues en la db y asi con lo que ya explique anteriormente

Por virla

4 de clabLevel



Genero:Masculino  

msie7
Citar            
MensajeEscrito el 16 Jul 2008 03:02 pm
Hacerlo mediante javascript es:
  • - Inseguro. (Cualquiera puede engañarle)
  • - Poco funcional. (Muchos navegamos con JS desactivado, y otros no lo tienen "instalado")
Por ello, deberías hacerlo desde ASP.

Pero si te empeñas...
Monta un esquema de lo que quieres... Y una página con los campos e imputs definitivos... para que veamos exactamente lo que quieres.

Por El Oso Amoroso

Claber

1780 de clabLevel

6 tutoriales

 

Madrid, España, Europa, Eurasia, La Tierra, Sist.Solar, Vía Láctea, UNIVERSO

firefox
Citar            
MensajeEscrito el 16 Jul 2008 03:19 pm
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

Por virla

4 de clabLevel



Genero:Masculino  

msie7
Citar            
MensajeEscrito el 16 Jul 2008 03:55 pm
Me rindo...
:(

PD1: es javascript.
PD2: consejo

Por El Oso Amoroso

Claber

1780 de clabLevel

6 tutoriales

 

Madrid, España, Europa, Eurasia, La Tierra, Sist.Solar, Vía Láctea, UNIVERSO

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.