FileUploader Foldername

Feb 19, 2009 at 10:50 PM

I tested like below. It works fine. however, I need to upload into different folders depending on user.
Is there any way to change the value for "FolderName" dynamically (I prefer in codebehind file) not static like below?
if there is then is there example for that?



fjx:FileUploader ID="FileUploader1" runat="server" >






<fjx:FileSaverAdapter runat="server" FolderName="FOLDER1" />



<fjx:ThumbGeneratorAdapter FolderName="FOLDER1" Suffix="_thumb" MaximumWidth="200" MaximumHeight="30000" />








Feb 20, 2009 at 1:02 AM
Edited Feb 20, 2009 at 1:03 AM
You can do that in the OnInit event of the page as:

protected override void OnInit(EventArgs e) {
((FileSaverAdapter) FileUploader1.Adapters[0]).FolderName = "NewFolder";



Feb 20, 2009 at 4:17 AM
Thanks for this info, I was also trying to set the thumb path also.
So with this I found out how to do it all.

here is my code to create the folders and sub folders in VB
This may help others using VB code

Private Const PathUsed As String = "FilesUploaded"    'Main folder for images
Private Const PathUsed_thumb As String = PathUsed & "/thumbs"    ' Sub Folder for Thumbnail

    Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs)
        DirectCast(FileUploader1.Adapters(0), FileSaverAdapter).FolderName = PathUsed
        DirectCast(FileUploader1.Adapters(1), ThumbGeneratorAdapter).FolderName = PathUsed_thumb

    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    End Sub

    Protected Sub CreateFolders()
        'this will create folder that are need for this page
        'upload and a sub folder thumbs
        'The folders are related to where the page file is


        'Create the Upload directory if it does not exist.
        Dim strUploadFolder As String
        Dim myUploadpath As String = Server.MapPath(".")
        strUploadFolder = myUploadpath + "/" & PathUsed & "/"
        If (Not Directory.Exists(strUploadFolder)) Then
        End If

        'Create the thumbs directory if it does not exist.
        Dim strthumbsFolder As String
        Dim mythumbspath As String = Server.MapPath(".")
        strthumbsFolder = mythumbspath + "/" & PathUsed_thumb & "/"
        If (Not Directory.Exists(strthumbsFolder)) Then
        End If
    End Sub