Upload from Standard Button

Jun 24, 2009 at 8:25 AM

1st. Awesome component. Thanks for releasing it under MIT. I have accomplished some simple uploads in testing but need it to do some dynamic uploads.

Here is what I want to accomplish.

a page with a textbox. User fill in textbox(txtnewgalleryname), select some images to upload via flajaxian. Click a standard button (btninsertimages), a folder is created, flajaxian uploads all the selected files to that directory.

So far the directory creation is working. I am not sure how to get flajaxian to upload the files from a standard button event. I am out of ideas. See vb code below, its been edited to hide private data.

Thanks for any suggestions.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Copy of CreateGallery.aspx.vb" Inherits="gallery2" %>
<%@ Register TagPrefix="fjx" Namespace="com.flajaxian" Assembly="com.flajaxian.FileUploader" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .style1
        {
            width: 34%;
            height: 87px;
        }
    </style>
   

   
   
</head>
<body>

 

    <form id="form1" runat="server">
    <div>
    
    
        <br />
        <h1>
            Create Gallery
        </h1>
        <br />
        <table class="style1">
            
            <tr>
                <td>
                    Name</td>
                <td>
        <asp:TextBox ID="txtNewGalleryName" runat="server" Width="294px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Upload Images</td>
                <td>
               
                    <fjx:FileUploader AllowedFileTypes="Web Images (Jpeg, Gig, Png):*.jpg;*.jpeg;*.png;*.gif" ID="FileUploader1" runat="server" >
    <Adapters>
     <fjx:FileSaverAdapter Runat="server" />
      
    <%--    <fjx:ThumbGeneratorAdapter Runat="server"
            Extensions="jpg;jpeg" FolderName="Images\Galleries"
             MaximumWidth="200" MaximumHeight="200" />--%>

    </Adapters>
</fjx:FileUploader>

                </td>
            </tr>
                <br />
        <br />
   
    </div>
    <asp:Button ID="btnInsertImage" runat="server" Text="Insert Data"    />
    <br />
    <br />
    <asp:Label ID="lblAlarm" runat="server" style="color: #FF0000"></asp:Label>
    <br />
    </form>
</body>
</html>

 

 

 

<<code behind>>>


Imports System.IO
Imports com.flajaxian
Partial Class gallery2
    Inherits System.Web.UI.Page
       Dim strUploadFolder As String
    'refresh the page
   
Public Sub ReFresh()
        Dim currentPage As String
        currentPage = "default.aspx"
        Response.Redirect(currentPage)

    End Sub

    Public Sub CreateFolder()
        Dim directory As Directory
        Dim newgalleryname As String
        newgalleryname = txtNewGalleryName.Text
        Dim myUploadpath As String = Server.MapPath(".")
        strUploadFolder = myUploadpath + "\Images\Galleries\" + newgalleryname
        If (Not directory.Exists(strUploadFolder)) Then
            directory.CreateDirectory(strUploadFolder)
        End If

    End Sub

Protected Sub btnInsertImage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnInsertImage.Click
       

        'create folder
        CreateFolder()

 'set folder to upload to
        setUploadFoder()
 
 'refresh page
        ReFresh()


    End Sub

Public Sub setUploadFoder()

'set folder and upload?
       DirectCast(FileUploader1.Adapters(0), FileSaverAdapter).FolderName = strUploadFolder
End Sub