Subir un fichero

28/07/2004 - 12:24 por raul | Informe spam
Hola

Soy nuevo en este mundillo, y a ver si hay alguien que pueda orientarme.
Quisiera hacer una pagina web, que subiera un fichero del cliente al
servidor web a traves de http. El fichero siempre se encuentra en la
misma ruta ("c:\datos\fichero1.txt"), y quisiera que lo hiciera
automaticamente, que cada vez que ejecute la pagina subiera el fichero.

¿como podria hacer esto?

Gracias
 

Leer las respuestas

#1 Franco Figún
28/07/2004 - 16:16 | Informe spam
<script language="VB" runat=server>
Sub DoUpload(Sender As Object, e As System.EventArgs)
Dim sPath as String
Dim sFile as String
Dim sFullPath as String
Dim sSplit() as String
Dim sPathFriendly as String

sPath = Server.MapPath(".")
If Right(sPath, 1) <> "\" then
sPathFriendly = sPath 'Friendly path name for display
sPath = sPath & "\"
Else
sPathFriendly = Left(sPath, Len(sPath) - 1)
End If
sFile = txtUpload.PostedFile.FileName
sSplit = Split(sFile, "\")
sFile = sSplit(Ubound(sSplit))

sFullPath = sPath & sFile
Try
txtUpload.PostedFile.SaveAs(sFullPath)
lblResults.Text = "Upload of File " & sFile & " to " &
sPathFriendly & " succeeded"

Catch Ex as Exception

lblResults.Text = "Upload of File " & sFile & " to " & sPathFriendly & "
failed for the following

reason: " & Ex.Message
Finally
lblResults.Font.Bold = True
lblResults.Visible = true
End Try
End Sub
</script>
<html><body>
<form enctype="multipart/form-data" runat=server>
<FONT face = +1><B>
Select File To Upload:</b></FONT>
<input id="txtUpload" type=file runat=server>
<asp:button id=btnUpload Text="Upload File" OnClick="DoUpload"
runat=server/>
<hr noshade>
<asp:label id="lblResults" Visible=false runat=server/>
</form>
</body>
</html>

FF
www.francofigun.com.ar
www.microsofties.com.ar
Yahoo MSN:

"raul" wrote in message
news:
Hola

Soy nuevo en este mundillo, y a ver si hay alguien que pueda


orientarme.
Quisiera hacer una pagina web, que subiera un fichero del cliente al
servidor web a traves de http. El fichero siempre se encuentra en la
misma ruta ("c:\datos\fichero1.txt"), y quisiera que lo hiciera
automaticamente, que cada vez que ejecute la pagina subiera el fichero.

¿como podria hacer esto?

Gracias


Preguntas similares