<?xml version="1.0" encoding="iso-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Foro Vida Una : Como hacer upload de ficheros al servidor</title>
  <link>https://www.vidauna.com/</link>
  <description><![CDATA[This is an XML content feed of; Foro Vida Una : C&#243;digos ASP y ASP.NET : Como hacer upload de ficheros al servidor]]></description>
  <pubDate>Sat, 04 Apr 2026 18:34:46 +0000</pubDate>
  <lastBuildDate>Sat, 09 May 2009 16:31:45 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.07</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>https://www.vidauna.com/RSS_post_feed.asp?TID=206</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Foro Vida Una]]></title>
   <url>https://www.vidauna.com/images/vidauna_logo.gif</url>
   <link>https://www.vidauna.com/</link>
  </image>
  <item>
   <title><![CDATA[Como hacer upload de ficheros al servidor : Este ejemplo nos muestra como...]]></title>
   <link>https://www.vidauna.com/como-hacer-upload-de-ficheros-al-servidor_topic206_post665.html#665</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://www.vidauna.com/member_profile.asp?PF=110">Programador</a><br /><strong>Subject:</strong> 206<br /><strong>Posted:</strong> 09&nbsp;Mayo&nbsp;2009 at 4:31pm<br /><br /><P>Este ejemplo nos muestra como subir un fichero desde el disco duro del cliente a un directorio de nuestro servidor; consta de un solo modulo que realiza las funciones de selección del fichero para upload (case 1) y las de la transmisión propiamente dicha (case 2)</P><P>saveany.asp</P><P>&lt;<a href="mailto:%@LANGUAGE=VB&#083;CRIPT%" target="_blank">%@LANGUAGE="VBSCRIPT"%</A>&gt;<BR>&lt;%response.buffer=true<BR>Func = Request("Func")<BR>if isempty(Func) Then<BR>Func = 1<BR>End if<BR>Select Case Func<BR>Case 1<BR>%&gt;</P><P>&lt;table width="360" border="0" align="center"&gt;<BR>&lt;tr&gt;<BR>&lt;td&gt; <BR>&lt;div align="center"&gt;Selecciona una imagen para subir. &lt;/div&gt;<BR>&lt;/td&gt;<BR>&lt;/tr&gt;<BR>&lt;/table&gt;<BR>&lt;FORM ENCTYPE="multipart/form-data" ACTION="saveany.asp?func=2" METHOD=POST id=form1 name=form1&gt; <BR>&lt;TABLE align="center"&gt;<BR>&lt;TR&gt; <BR>&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;<BR>&lt;/TR&gt;<BR>&lt;TR&gt; <BR>&lt;TD&gt;&lt;font color="#330066" size="2"&gt;Pulsa en el botón examinar y elige el archivo <BR>de tu ordenador.&lt;BR&gt;<BR>&lt;BR&gt;<BR>&lt;/font&gt;&lt;/TD&gt;<BR>&lt;/TR&gt;<BR>&lt;TR&gt; <BR>&lt;TD&gt;&lt;font color="#330066" size="2"&gt;Luego pulsa el botón subir.&lt;BR&gt;<BR>&lt;BR&gt;<BR>&lt;/font&gt;&lt;/TD&gt;<BR>&lt;/TR&gt;<BR>&lt;TR&gt; <BR>&lt;TD&gt;&lt;STRONG&gt;&lt;font color="#330066" size="2"&gt;Nombre del archivo...&lt;/font&gt;&lt;/STRONG&gt;&lt;/TD&gt;<BR>&lt;/TR&gt;<BR>&lt;TR&gt; <BR>&lt;TD&gt; &lt;font size="2"&gt; <BR>&lt;INPUT NAME=File1 SIZE=30 TYPE=file&gt;<BR>&lt;BR&gt;<BR>&lt;/font&gt;&lt;/TD&gt;<BR>&lt;/TR&gt;<BR>&lt;TR&gt; <BR>&lt;TD align=left&gt; <BR>&lt;INPUT type="submit" value="Subir"&gt;<BR>&lt;BR&gt;<BR>&lt;BR&gt;<BR>&lt;/TD&gt;<BR>&lt;/TR&gt;<BR>&lt;TR&gt; <BR>&lt;TD&gt;&lt;font color="#330066" size="2"&gt;NOTA: Espera, recibirás una notificación <BR>cuando el archivo haya sido subido&lt;/font&gt;&lt;font size="2"&gt;.&lt;BR&gt;<BR>&lt;BR&gt;<BR>&lt;/font&gt;&lt;/TD&gt;<BR>&lt;/TR&gt;<BR>&lt;/TABLE&gt;<BR>&lt;%<BR>Case 2<BR>ForWriting = 2<BR>adLongVarChar = 201<BR>lngNumberUploaded = 0</P><P>'Get binary data from form <BR>noBytes = Request.TotalBytes <BR>binData = Request.BinaryRead (noBytes)<BR>'convery the binary data to a string<BR>Set RST = CreateObject("ADODB.Recordset")<BR>LenBinary = LenB(binData)</P><P>if LenBinary &gt; 0 Then<BR>RST.Fields.Append "myBinary", adLongVarChar, LenBinary<BR>RST.Open<BR>RST.AddNew<BR>RST("myBinary").AppendChunk BinData<BR>RST.Update<BR>strDataWhole = RST("myBinary")<BR>End if<BR>'Creates a raw data file for with all da<BR>' ta sent. Uncomment for debuging. <BR>'Set fso = CreateObject("Scripting.FileSystemObject")<BR>'Set f = fso.OpenTextFile(server.mappath(".") &amp; "\raw.txt", ForWriting, True)<BR>'f.Write strDataWhole<BR>'set f = nothing<BR>'set fso = nothing<BR>'get the boundry indicator<BR>strBoundry = Request.ServerVariables ("HTTP_CONTENT_TYPE")<BR>lngBoundryPos = instr(1,strBoundry,"boundary=") + 8 <BR>strBoundry = "--" &amp; right(strBoundry,len(strBoundry)-lngBoundryPos)<BR>'Get first file boundry positions.<BR>lngCurrentBegin = instr(1,strDataWhole,strBoundry)<BR>lngCurrentEnd = instr(lngCurrentBegin + 1,strDataWhole,strBoundry) - 1<BR>Do While lngCurrentEnd &gt; 0<BR>'Get the data between current boundry an<BR>' d remove it from the whole.<BR>strData = mid(strDataWhole,lngCurrentBegin, lngCurrentEnd - lngCurrentBegin)<BR>strDataWhole = replace(strDataWhole,strData,"")</P><P>'Get the full path of the current file.<BR>lngBeginFileName = instr(1,strdata,"filename=") + 10<BR>lngEndFileName = instr(lngBeginFileName,strData,chr(34)) <BR>'Make sure they selected at least one fi<BR>' le. <BR>if lngBeginFileName = lngEndFileName and lngNumberUploaded = 0 Then</P><P>Response.Write "&lt;H2&gt; Ha ocurrido el siguiente error.&lt;/H2&gt;"<BR>Response.Write "Debes elegir un archivo para subir"<BR>Response.Write "&lt;BR&gt;&lt;BR&gt;Pulsa el botón volver, realiza la corrección."<BR>Response.Write "&lt;BR&gt;&lt;BR&gt;&lt;INPUT type='button' onclick='history.go(-1)' value='&lt;&lt; Volver' id='button'1 name='button'1&gt;"<BR>Response.End <BR>End if<BR>'There could be one or more empty file b<BR>' oxes. <BR>if lngBeginFileName &lt;&gt; lngEndFileName Then<BR>strFilename = mid(strData,lngBeginFileName,lngEndFileName - lngBeginFileName)<BR>'Creates a raw data file with data betwe<BR>' en current boundrys. Uncomment for debug<BR>' ing. <BR>'Set fso = CreateObject("Scripting.FileSystemObject")<BR>'Set f = fso.OpenTextFile(server.mappath(".") &amp; "\raw_" &amp; lngNumberUploaded &amp; ".txt", ForWriting, True)<BR>'f.Write strData<BR>'set f = nothing<BR>'set fso = nothing</P><P>'Loose the path information and keep jus<BR>' t the file name. <BR>tmpLng = instr(1,strFilename,"\")<BR>Do While tmpLng &gt; 0<BR>PrevPos = tmpLng<BR>tmpLng = instr(PrevPos + 1,strFilename,"\")<BR>Loop</P><P>FileName = right(strFilename,len(strFileName) - PrevPos)</P><P>'Get the begining position of the file d<BR>' ata sent.<BR>'if the file type is registered with the<BR>' browser then there will be a Content-Typ<BR>' e<BR>lngCT = instr(1,strData,"Content-Type:")</P><P>if lngCT &gt; 0 Then<BR>lngBeginPos = instr(lngCT,strData,chr(13) &amp; chr(10)) + 4<BR>Else<BR>lngBeginPos = lngEndFileName<BR>End if<BR>'Get the ending position of the file dat<BR>' a sent.<BR>lngEndPos = len(strData) </P><P>'Calculate the file size. <BR>lngDataLenth = lngEndPos - lngBeginPos<BR>'Get the file data <BR>strFileData = mid(strData,lngBeginPos,lngDataLenth)<BR>'Create the file. <BR>Set fso = CreateObject("Scripting.FileSystemObject")<BR>Set f = fso.OpenTextFile(server.mappath("..") &amp; "\TuDirectorio\" &amp;_<BR>&nbsp;FileName, ForWriting, True)<BR>f.Write strFileData<BR>Set f = nothing<BR>Set fso = nothing</P><P>lngNumberUploaded = lngNumberUploaded + 1</P><P>End if</P><P>'Get then next boundry postitions if any<BR>' .<BR>lngCurrentBegin = instr(1,strDataWhole,strBoundry)<BR>lngCurrentEnd = instr(lngCurrentBegin + 1,strDataWhole,strBoundry) - 1<BR>loop</P><P><BR>Response.Write "Archivo subido"<BR>Response.Write lngNumberUploaded &amp; " archivo ya está en el servidor.&lt;BR&gt;"<BR>Response.Write "&lt;BR&gt;&lt;BR&gt;&lt;INPUT type='button' onclick='document.location=" &amp; chr(34) &amp; "saveany.asp" &amp; chr(34) &amp; "' value='&lt;&lt; Volver' id='button'1 name='button'1&gt;" <BR>End Select <BR>%&gt;<BR>&lt;/BODY&gt;<BR>&lt;/HTML&gt;<BR></P>]]>
   </description>
   <pubDate>Sat, 09 May 2009 16:31:45 +0000</pubDate>
   <guid isPermaLink="true">https://www.vidauna.com/como-hacer-upload-de-ficheros-al-servidor_topic206_post665.html#665</guid>
  </item> 
 </channel>
</rss>