Getting the filename after it has uploaded?

Nov 25, 2008 at 3:35 PM
I have created a upload page using this control and i get it all to work, so my files do upload. But i need to access the uploaded filename when a submit button is clicked.

How do a get the filename?
Code below.

mports System.IO
Imports System.Net
Imports System.Net.Mail
Imports Subgurim
Imports Subgurim.Controles
Partial Class Default2
    Inherits System.Web.UI.Page

    Dim pf As New HttpPostedFileAJAX

    Protected Sub page_load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load

            FileUploaderAJAX1.text_Add = "Upload File"
            FileUploaderAJAX1.text_Delete = "Remove File"
            FileUploaderAJAX1.text_Uploading = "Uploading File..."
            FileUploaderAJAX1.text_X = "Close"
            If (True = FileUploaderAJAX1.IsPosting) Then
                If (pf.ContentLength <= (5 * 1024)) Then
                End If
            End If
        Catch ex As Exception

        End Try
    End Sub

    Private Sub managePost1()
        pf.FileName = FileUploaderAJAX1.PostedFile.FileName
        FileUploaderAJAX1.SaveAs("~/temp/", pf.FileName)
    End Sub

    Protected Sub btSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btSubmit.Click
        Dim objSendEmail As New clsEmail
        Dim templateVars As New Hashtable()
        Dim tempfilename As String = 'I need the uploaded filename here?
   End Sub

Dec 11, 2008 at 9:44 PM
Edited Dec 11, 2008 at 10:12 PM
you can get the filename via the Historical data.  I use this code to get the very last image that was uploaded (C#)

        if(FileUploaderAJAX1.historial.Count > 0)
            string newThumbnail = FileUploaderAJAX1.historial[FileUploaderAJAX1.historial.Count - 1].FileName_SavedAs;


        If (FileUploaderAJAX1.historial.Count > 0) Then
            Dim newThumbnail As String = FileUploaderAJAX1.historial(FileUploaderAJAX1.historial.Count - 1).FileName_SavedAs
        End If

EDIT:  I apparently have an older version, so depending on which version you have, you may have to replace 'historical' with 'History'
Dec 12, 2008 at 7:15 AM
Thank you very much, works well.