Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5.1 > ASP.NET 4.5.1 General Discussion
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 4.5.1 General Discussion For ASP.NET 4.5.1 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4.5.1 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old June 12th, 2017, 06:25 PM
Registered User
Points: 13, Level: 1
Points: 13, Level: 1 Points: 13, Level: 1 Points: 13, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Feb 2017
Location: Houston, TX
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default HttpFileCollectionBase Cannot get uploads

I'm using request.files as HttpFileCollectionBase and passing them into the Class File using a public variable. The count property is 1 even no file is upload so I don't know how to if file upload before call the construct method.

I also cannot iterate the collection. The P_ variables are class private passed in from the public property assignments.

The construct method:

    Private p_filesToAttach As HttpFileCollectionBase

    Public Property FilesToAttach() As HttpFileCollectionBase
            Return p_filesToAttach
        End Get
        Set(ByVal value As HttpFileCollectionBase)
            p_filesToAttach = value
        End Set
    End Property

Public Sub ConstructUpload()
        ' Get full path to the attachments folder
        Dim FolderPath As String = Current.Server.MapPath(p_attachmentFolder) + "\"
        Dim strFileName As String = ""
        Dim httpFiles = p_filesToAttach
        Dim i = p_filesToAttach.Count

            For Each upfile In httpFiles
                'Dim upfile As HttpPostedFileBase =
                If upfile.ContentLength > 0 Then
                    Current.Response.Write("this is it")
                End If

                strFileName = Path.GetFileName(upfile.FileName)
                'verify file exists

                If Not String.IsNullOrEmpty(strFileName) Then
                    'set file paths
                    Dim filePath As String = FolderPath + GetFilePath(strFileName)
                    If Not (upfile) Is Nothing Then
                    End If

                    'check file size
                    If upfile.ContentLength > (250 * 1000) Then
                        Throw New WebException("Upload file:" & strFileName & " exceeds the allowed size of: " & (p_attachmentMaxLength * 1000) & " kilobytes.")
                        'Create the directory if it does not exist.
                        If (Not Directory.Exists(FolderPath)) Then
                            If CheckFolderPermissions(FolderPath) Then
                                Throw New WebException("You don't have permission to attach the file: " & strFileName & ".")
                            End If
                        End If
                        ' Delete existing files with same name before uploading new.
                        If File.Exists(filePath) Then
                            If CheckFolderPermissions(FolderPath) Then
                                Throw New WebException("You don't have permission to attach the file: " & strFileName & ".")
                            End If
                        End If
                        ' Call UploadAttachments to upload the file.
                        UploadFiles(upfile, upfile.FileName, FolderPath)
                    End If
                    Throw New WebException("Upload file cannot be found.")
                End If
        Catch e As WebException
        End Try

    End Sub ' ConstructUpload
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
asp uploads red_fiesta Classic ASP Basics 0 October 17th, 2007 04:28 AM
File Uploads seananderson Classic ASP Basics 1 November 14th, 2006 11:29 AM
How to add more file uploads? fyp4135 C# 2005 3 November 8th, 2006 10:55 PM
Multiple file uploads felixDa BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 2 April 17th, 2006 10:37 AM

All times are GMT -4. The time now is 07:57 AM.

Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.