Does this control support DotNetNuke?

May 11, 2009 at 4:57 AM

Hi,

I am trying to get this control to work in my localhost environment.  If I can get it to work, I'd like to purchase the direct to Amazon S3 option.

But I've followed the instructions and I get no events on the server and no file is uploaded, although the progress bar runs to completion.  This is inside a DotNetNuke module, and DNN parses the code.  It may be affecting this.

Here's my ascx, which has a form.  One item on the form is the file upload.  After the upload completes, the user fills out the rest of the form and submits, causing a postback.  I need the filename in that postback.  I'm hoping to find it in FileUploader1.Text or something, but I don't get that far:

<%@ Register TagPrefix="fjx" Namespace="com.flajaxian" Assembly="com.flajaxian.FileUploader" %>

... Bunch of items on the form.  Then...


Choose MP3 file to upload:
<br />
<fjx:FileUploader ID="FileUploader1" runat="server" >
    <Adapters>
        <fjx:FileSaverAdapter Runat="server" FolderName="UploadFolder" />
    </Adapters>
</fjx:FileUploader>

 

And here is the rendered code, after DNN has massaged it:

Choose MP3 file to upload:
<br />
<div id="dnn_ctr472_EditTalk_FileUploader1">
<a href="http://get.adobe.com/flashplayer/" target="_blank">Please install Adobe Flash Player</a>
</div>
<script type="text/javascript" language="javascript">
window.dnn_ctr472_EditTalk_FileUploader1 = new Flajaxian.FileUploader2('dnn_ctr472_EditTalk_FileUploader1');
function dnn_ctr472_EditTalk_FileUploader1_MarkInitialized(){ window.dnn_ctr472_EditTalk_FileUploader1.markInitialized(); }
function dnn_ctr472_EditTalk_FileUploader1_SetFileList(list){ window.dnn_ctr472_EditTalk_FileUploader1.setFileList(list); }
function dnn_ctr472_EditTalk_FileUploader1_SetUploadProgress(evt){ window.dnn_ctr472_EditTalk_FileUploader1.setUploadProgress(evt); }
function dnn_ctr472_EditTalk_FileUploader1_SetChangedFileStates(list){ window.dnn_ctr472_EditTalk_FileUploader1.setChangedFileStates(list); }
function dnn_ctr472_EditTalk_FileUploader1_LimitReached(type){ window.dnn_ctr472_EditTalk_FileUploader1.limitReached(type); }
function dnn_ctr472_EditTalk_FileUploader1_ConfirmUpload(){ window.dnn_ctr472_EditTalk_FileUploader1.confirmUpload(); }
function dnn_ctr472_EditTalk_FileUploader1_Dispose(){ window.dnn_ctr472_EditTalk_FileUploader1.dispose(); }
function dnn_ctr472_EditTalk_FileUploader1_EmbedFlash(){
var p = {menu:false,base:'.',scale:'noscale',bgcolor:'#FFFFFF'};
var a = {};
var fv = {id:"dnn_ctr472_EditTalk_FileUploader1",targetUrl:"http://localhost/DNN501/Default.aspx?__ID=dnn_ctr472_EditTalk_FileUploader1_(!AMP!)___AspCookie.Session=pzjvh3ao5j1zx3mpfrvsde45_(!AMP!)___AspCookie.Auth=106C7A82E79C49D3866E271EEC3C5D8116B77D42E6CD8F06E6F108E661EA82F27654FCE15B233B637CE5534EA8CBFBFA0CC204BFC9C2BC8C60BB0E80D3D396D63F9B146D7D4B5768_(!AMP!)_",debug:false,enabled:true,isIE:Flajaxian.isIE(),clearListAtEnd:true,uploadRequiresJsConfirmation:false,initiallyInvisible:false,maxFileSize:1072668082176,maxFileQueueSize:1072668082176,maxFileNumberLimit:2147483647};
swfobject.embedSWF("/DNN501/WebResource.axd?d=47Y84IWnLrSeKl1mCVHMve-kkIlUivMFL9eQ-y8NUnhev1yjMq75d5N9th7MFhxt-8EwPb7sG3SyuOLKAmc2VHiLxvbLeqoq0&t=633775844265300000", "dnn_ctr472_EditTalk_FileUploader1", "251", "40", "9.0.0", "/DNN501/WebResource.axd?d=47Y84IWnLrSeKl1mCVHMve-kkIlUivMFL9eQ-y8NUnhev1yjMq75d5N9th7MFhxtJ_WHypQFF0xsbO9SdOnLUkMgwZpIRK_Q0&t=633775844265300000", fv, p, a);
var fu = window.dnn_ctr472_EditTalk_FileUploader1;
fu.set_generateBaseHtmlFunc(Flajaxian.generateBaseHtml);
fu.set_generateFileRowFunc(Flajaxian.generateFileRow);
fu.set_disposeFileRowFunc(Flajaxian.disposeFileRow);
fu.set_fileStateChangedFunc(Flajaxian.fileStateChanged);
fu.set_percentageChangedFunc(Flajaxian.percentageChangedFunc);
fu.set_maxFileNumberReachedFunc(Flajaxian.maxFileNumberReached);
fu.set_maxFileSizeReachedFunc(Flajaxian.maxFileSizeReached);
fu.set_maxQueueSizeReachedFunc(Flajaxian.maxQueueSizeReached);
fu.set_positionFilesListFunc(Flajaxian.positionFilesList);
fu.set_renderFilesListFunc(Flajaxian.renderFilesList);
fu.set_strings({maxFileNumberReached:'The maximum number of files allowed to be selected of \'2147483647\' has been reached.',maxFileSizeReached:'The maximum allowed file size of \'999GB\' has been exceeded.',maxQueueSizeReached:'The maximum allowed size of \'999GB\' for all the files in the queue has been exceeded.'});
fu.set_openedArrowUrl("/DNN501/WebResource.axd?d=47Y84IWnLrSeKl1mCVHMve-kkIlUivMFL9eQ-y8NUnhev1yjMq75d3HsjomKO-YUavkboZ3asOJRLQYbiACmq4Bo46tPwg6j0&t=633775844265300000");
fu.set_closedArrowUrl("/DNN501/WebResource.axd?d=47Y84IWnLrSeKl1mCVHMve-kkIlUivMFL9eQ-y8NUnhev1yjMq75d3HsjomKO-YU-EnKIZIwH2_KgRA_bKRXH1PrG3g2Hbxg0&t=633775844265300000");
fu.set_closeBtnUrl("/DNN501/WebResource.axd?d=47Y84IWnLrSeKl1mCVHMve-kkIlUivMFL9eQ-y8NUnhev1yjMq75d3HsjomKO-YUICAhbKW0mCq6PjA11osIP-WAivj6v4OE0&t=633775844265300000");
fu.set_flashWidth(251);
fu.set_flashHeight(40);
fu.set_uploadRequiresJsConfirmation(false);
fu.set_clearListAtEnd(true);
fu.initialize();
}
dnn_ctr472_EditTalk_FileUploader1_EmbedFlash();
</script>

Should that work?

Thanks for your help.

 

Coordinator
May 11, 2009 at 5:09 AM

Check this

http://flajaxian.com/flajaxian.com/FileUploader2.0Help.html#HowToOvercomeFlashBug

And if you have problems like that use Fiddler to see what is the server response

May 11, 2009 at 6:26 AM

global.asax.vb is part of the DNN core and I don't really have access to it unless I want to fork the code (and besides, it's in VB ;-)

I'm writing extensions at the user control level.  How do I do fix this solely in an ascx or C# code behind?

Also, this doesn't work in IE7, either.  I've installed fiddler.  Will see what I come up with.

May 11, 2009 at 10:34 PM
Okay, I must have missed something very basic, here.  I spent some time with Fiddler, and was not able to reliably get it to trace localhost traffic, even with the workarounds suggested on their site, so I backed off and tried something very simple: a one page site with just your control.  No DNN.  Just .net.  Here's my complete application:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ 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>
</head>
<body>
    <form id="form1" runat="server">
   



Choose MP3 file to upload:


<fjx:FileUploader ID="FileUploader1" runat="server" >
    <Adapters>
        <fjx:FileSaverAdapter Runat="server" FolderName="UploadFolder" />
    </Adapters>
</fjx:FileUploader>
      

    </form>
</body>
</html>

And the code behind:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        FileUploader1.FileReceived += new EventHandler<com.flajaxian.FileReceivedEventArgs>(FileUploader1_FileReceived);
    }

    void FileUploader1_FileReceived(object sender, com.flajaxian.FileReceivedEventArgs e)
    {
        throw new NotImplementedException();
    }
}

I get the same behavior in FF and IE.  Control renders, I pick a 10MB file and click "upload."  Control pauses about 2 secs with no updates on progress bar, then the "cancel" button disappears.  I receive no "FileReceived" callback.  The file does not appear in the "UploadFolder."  I see no HTTP requests from the browser in Firebug or Fiddler (although Fiddler on localhost has not been reliable for me).

What's up?  I'm on Vista/IIS7/VS2008.

AldenG

On Sun, May 10, 2009 at 9:09 PM, flajaxian <notifications@codeplex.com> wrote:

From: flajaxian

Check this

http://flajaxian.com/flajaxian.com/FileUploader2.0Help.html#HowToOvercomeFlashBug

And if you have problems like that use Fiddler to see what is the server response

Read the full discussion online.

To add a post to this discussion, reply to this email (FlajaxianFileUpload@discussions.codeplex.com)

To start a new discussion for this project, email FlajaxianFileUpload@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Alden Gannon
Owner, Six Fish, LLC.
206.201.2566
Skype alden_gannon
Coordinator
May 11, 2009 at 11:09 PM

To get fiddler working on localhost use http://geekswithblogs.net/PartialMethod/archive/2009/02/06/debug-localhost-with-fiddler-2.aspx

Also FileReceived should be attached OnInit not OnLoad and preferably even in the markup as

<fjx:FileUploader ID="FileUploader1" runat="server" OnFileReceived="FileUploader1_FileReceived">
    <Adapters>
        <fjx:FileSaverAdapter Runat="server" FolderName="UploadFolder" />
    </Adapters>
</fjx:FileUploader>

May 12, 2009 at 1:02 AM

Thanks for your reply.  By following the instructions on the flajaxian site, I was able to get the control to work corrently in my one-page site.

BTW, the code here doesn't work: http://flajaxian.com/flajaxian.com/FileUploader2.0Help.html#HowToOvercomeFlashBug

You can't name your event handler BeginRequest.  Better change that in the doc.

However, I still have the same scenario in the DNN site with the same code as the one-page site: no event fires, file not uploaded in IE or FF.  I found an event that was called on BeginRequest and added the cookie registration code, but that had no effect.  I presume it should work in IE without this code, anyway.  What should I do next?

May 12, 2009 at 11:25 PM

Okay, still trying to get this to work in DNN.  This time I created a new blank DNN module (a user control, basically) with only this control in it.  I added this module to this page: http://simsbeta.com/Talks/TestUpload/tabid/127/Default.aspx

I get strange and intermittent results, here.  Used Fiddler and Firebug, but they seem to report different things even on back-to-back uploads. 

Regardless, I never get the "FileReceived" event on the server -- it will throw an exception if I do.   And I never see content in the UploadFolder.  Can you take a look at that page and see what's going on?  Source code follows.

The module (user control):

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="testupload.ascx.cs" Inherits="DotNetNuke.Modules.DharmaTalks.testupload" %>
<%@ Register TagPrefix="fjx" Namespace="com.flajaxian" Assembly="com.flajaxian.FileUploader" %>

Choose MP3 file to upload:
<br />
<fjx:FileUploader ID="FileUploader1" runat="server" OnFileReceived="FileUploader1_FileReceived">
    <Adapters>
        <fjx:FileSaverAdapter Runat="server" FolderName="UploadFolder" />
    </Adapters>
</fjx:FileUploader>  

The code behind:

using System;

namespace DotNetNuke.Modules.DharmaTalks
{
    public partial class testupload : DotNetNuke.Entities.Modules.PortalModuleBase
    {

        protected void FileUploader1_FileReceived(object sender, com.flajaxian.FileReceivedEventArgs e)
        {
            throw new NotImplementedException();
        }
    }
}

Coordinator
May 12, 2009 at 11:30 PM

I have never used DotNetNukes so I can't speak on that. May be you can address the question to the DotNetNukes community?

Jul 22, 2010 at 9:18 PM

Hi folks,

I make it work; here is how I used it:

On the code behind:

        protected override void OnLoad(EventArgs e) {
            base.OnLoad(e);
            var fileSaverAdapter = new FileSaverAdapter() {
                FolderName = "~" + this.PortalSettings.HomeDirectory
            };
            var thumbAdapter = new ThumbGeneratorAdapter() {
                FolderName = "~" + this.PortalSettings.HomeDirectory,
                Extensions = "jpg;jpeg",
                Prefix = "thumb_",
                MaximumWidth = 200,
                MaximumHeight = 200
            };
            
            fileSaverAdapter.FileNameDetermining += OnFileNameDetermining;
            thumbAdapter.FileNameDetermining += OnFileNameDetermining;
            
            this.uplFileUploader.Adapters.Add(fileSaverAdapter);
            this.uplFileUploader.Adapters.Add(thumbAdapter);

            this.uplFileUploader.FileReceived += OnFileReceived;
            this.uplFileUploader.PageUrl = HttpContext.Current.Request.Url.AbsoluteUri;
            this.uplFileUploader.RequestAsPostBack = true;
        }

        private void OnFileNameDetermining(object sender, FileNameDeterminingEventArgs e) {
            string fileName = Path.GetFileNameWithoutExtension(e.FileName);
            string extension = Path.GetExtension(e.FileName);
            string path = Path.GetDirectoryName(e.FileName);
            int i = 1;
            while (File.Exists(e.FileName)) {
                e.FileName = Path.Combine(path, string.Format("{0}_{1}{2}", fileName, i, extension));
                i++;
            }
        }

        void OnFileReceived(object sender, FileReceivedEventArgs e) {

        }

On the .ascx control:

<%@ Register TagPrefix="fjx" Namespace="com.flajaxian" Assembly="com.flajaxian.FileUploader" %>
<fjx:FileUploader ID="uplFileUploader" runat="server" 
    MaxFileSize="5MB" 
    MaxFileSizeReachedMessage="No se aceptan archivos de más de {0}."
    MaxFileQueueSize="20MB"    
    MaxFileQueueSizeReachedMessage="El tamaño del lote de fotos no puede superar los {0}"
    MaxNumberFiles="20"
    MaxFileNumberReachedMessage="Sólo puede seleccionar hasta {0} archivos por lote."
    AllowedFileTypes="Imágenes (Jpeg, Gig, Png):*.jpg;*.jpeg;*.png;*.gif">
</fjx:FileUploader> 
 

I hope it help someone else =), by the way very nice work!! Flajaxian rocks!

Jul 22, 2010 at 9:22 PM
Wow, thanks! I may find a use for this in my next project. Awesome!

AldenG
206.201.2566
Excuse the brevity. Typed on my iPhone with fat clumsy thumbs.

On Jul 22, 2010, at 1:18 PM, "wpoch" <notifications@codeplex.com> wrote:

From: wpoch

Hi folks,

I make it work; here is how I used it:

On the code behind:

        protected override void OnLoad(EventArgs e) {
            base.OnLoad(e);
            var fileSaverAdapter = new FileSaverAdapter() {
                FolderName = "~" + this.PortalSettings.HomeDirectory
            };
            var thumbAdapter = new ThumbGeneratorAdapter() {
                FolderName = "~" + this.PortalSettings.HomeDirectory,
                Extensions = "jpg;jpeg",
                Prefix = "thumb_",
                MaximumWidth = 200,
                MaximumHeight = 200
            };
            
            fileSaverAdapter.FileNameDetermining += OnFileNameDetermining;
            thumbAdapter.FileNameDetermining += OnFileNameDetermining;
            
            this.uplFileUploader.Adapters.Add(fileSaverAdapter);
            this.uplFileUploader.Adapters.Add(thumbAdapter);

            this.uplFileUploader.FileReceived += OnFileReceived;
            this.uplFileUploader.PageUrl = HttpContext.Current.Request.Url.AbsoluteUri;
            this.uplFileUploader.RequestAsPostBack = true;
        }

        private void OnFileNameDetermining(object sender, FileNameDeterminingEventArgs e) {
            string fileName = Path.GetFileNameWithoutExtension(e.FileName);
            string extension = Path.GetExtension(e.FileName);
            string path = Path.GetDirectoryName(e.FileName);
            int i = 1;
            while (File.Exists(e.FileName)) {
                e.FileName = Path.Combine(path, string.Format("{0}_{1}{2}", fileName, i, extension));
                i++;
            }
        }

        void OnFileReceived(object sender, FileReceivedEventArgs e) {

        }

On the .ascx control:

<%@ Register TagPrefix="fjx" Namespace="com.flajaxian" Assembly="com.flajaxian.FileUploader" %>
<fjx:FileUploader ID="uplFileUploader" runat="server" 
    MaxFileSize="5MB" 
    MaxFileSizeReachedMessage="No se aceptan archivos de más de {0}."
    MaxFileQueueSize="20MB"    
    MaxFileQueueSizeReachedMessage="El tamaño del lote de fotos no puede superar los {0}"
    MaxNumberFiles="20"
    MaxFileNumberReachedMessage="Sólo puede seleccionar hasta {0} archivos por lote."
    AllowedFileTypes="Imágenes (Jpeg, Gig, Png):*.jpg;*.jpeg;*.png;*.gif">
</fjx:FileUploader> 
 

I hope it help someone else =), by the way very nice work!! Flajaxian rocks!