Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Uploading Files ... Help me


Message #1 by "lilette Cardenas" <lunalilette@y...> on Tue, 25 Jun 2002 22:59:38
I can't upload Files

This is de error message:

Index was out of range. Must be non-negative and less than the size of 
the collection. Parameter name: index 
Description: An unhandled exception occurred during the execution of the 
current web request. Please review the stack trace for more information 
about the error and where it originated in the code. 

Exception Details: System.ArgumentOutOfRangeException: Index was out of 
range. Must be non-negative and less than the size of the collection. 
Parameter name: index

This mean that Request.Files is empty. I would like to know what's wrong
Help me please!!!

This is the code:


'''''''page''''''''

<body MS_POSITIONING="GridLayout">
<form id="Form1" method="get" enctype="multipart/form-data" 
runat="server">
	<INPUT id="Archivo" style="Z-INDEX: 101; LEFT: 174px; WIDTH: 
284px; POSITION: absolute; TOP: 94px; HEIGHT: 31px" type="file" size="28" 
runat="server">

........other tags .................
	<asp:Button id="btncancelar1" style="Z-INDEX: 105; LEFT: 309px; 
POSITION: absolute; TOP: 212px" runat="server" Height="33px" 
Width="115px" Text="Cancelar"></asp:Button>
</form>
</body>

'''''''''code begin''''''''''''
Private Sub btncargar_Click(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles btncargar.Click
Dim g As Integer = Val(Request.QueryString("gpo"))
        Dim us As String = Val(Session("nomusu"))
        Dim dp As Integer = Val(Request.QueryString("dp"))
        Dim prop As String = "true"
        Dim nuevonom As String
        Dim cont As Int32
        nuevonom = txtnombre.Text
        Dim i As Int32
        For i = 0 To Request.Files.Count
            Dim archivos As System.Web.HttpPostedFile = Request.Files
(i)         
            Dim ruta As String
            ruta = archivos.FileName
            Dim pos = InStr(Trim(ruta), ".", CompareMethod.Text)
            Dim extension As String = Mid(ruta, pos + 1, (Len(ruta) - 
pos))
            Dim tipo As String = archivos.ContentType
            Dim tamano As Integer = archivos.ContentLength
            Dim cadinfo As System.IO.Stream = archivos.InputStream
            Dim datosbin(tamano) As Byte
            Dim n As Integer = cadinfo.Read(datosbin, 0, tamano)
       '''' next save the file '''''''
       Next
       ............. more code
End Sub

  Return to Index