Ver Mensaje Individual
  #6 (permalink)  
Antiguo 15/09/2009, 01:09
Avatar de Laika
Laika
 
Fecha de Ingreso: octubre-2001
Mensajes: 1.376
Antigüedad: 22 años, 7 meses
Puntos: 0
Respuesta: Problemas con upload file en aspx

Lo solucioné. Este es el codigo que me funciona:

Código:
<%@ Import namespace="System.IO"%>
<html>
<head>
<title>Uploading a File</title>
<script language="VB" runat="server">

Dim savePath As String = "C:\prueba\"
Sub Upload_Click(source As Object, e As EventArgs)

If Not (uploadedFile.PostedFile Is Nothing) Then
Try
Dim postedFile = uploadedFile.PostedFile
Dim filename As String = Path.GetFileName(postedFile.FileName)
Dim contentType As String = postedFile.ContentType
Dim contentLength As Integer = postedFile.ContentLength

postedFile.SaveAs(savePath & filename)
message.Text = postedFile.Filename & " uploaded" & _
"<br>content type: " & contentType & _
"<br>content length: " & contentLength.ToString()
Catch exc As Exception
message.Text = "Failed uploading file"
End Try
End If
End Sub
</script>

</head>
<body>

<form enctype="multipart/form-data" runat="server">
Select File to Upload:
<input id="uploadedFile" type="file" runat="server">
<p>
<input type=button id="upload"
value="Upload"
OnServerClick="Upload_Click"
runat="server">
<p>
<asp:Label id="message" runat="server"/>
</form>

</body>
</html>
Parece que el problema estaba en los permisos de escritura en la carpeta de destino del fichero a subir.