Welcome Guest Search | Active Topics | Sign In | Register

Updater currentFileName() method Options
chris
Posted: Sunday, April 13, 2008 5:20:09 PM
Rank: Newbie
Groups: Member

Joined: 4/13/2008
Posts: 2
Hi there

I am using the file uploader and have javascript to handle 2 types of errors:

1. File is too big
2. The user is uploading something with the wrong file extension.


Now I've wired it up just fine, as it errors in both cases.

Code: HTML/ASPX
<EWe:AJAXUploader ID="uploader" 
    runat="server" 
    MaxDataSize="1000"  
    TempFileLocation="~/_tempdocs"  
    MaxFileCount="1" ClientSideOnError="UploadError"></EWe:AJAXUploader>


Code: JavaScript
function UploadError() {
    var uploader = eo_GetObject('uploader'); 
    var filename = uploader.getCurrentFileName();
    var fileExtensions = uploader.getAllowedExtension();
}



My questions is this: When I run the upload, I try to get back the current file name they've input and yet the javascript returns "Undefined". Am I misunderstanding the purpose of this method? Can I not get the name of the file at this stage?


The reason for this is simply to determine which type of error I have encountered. Did they attempt to upload a file thats too big or did they upload one which had the wrong file extension?
chris
Posted: Sunday, April 13, 2008 6:47:58 PM
Rank: Newbie
Groups: Member

Joined: 4/13/2008
Posts: 2
Well the best I can offer here is my finding of a partial solution:

the javascript function should contain the following signature:

function OnUploadError(control, error, message)


In this way, you can read the error as a string and thus determine what type of error you are dealing with.


eo_support
Posted: Sunday, April 13, 2008 7:04:37 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
Hi,

Your JavaScript function should be something like this:

Code: JavaScript
function UploadError(uploader, error, message)
{
    if (error == "max_size_exceeded")
    {
        window.alert("file is too big!");
    }
    else if (error == "extension_not_allowed")
    {
        window.alert("invalid file extension!");
    }
}


The uploader calls this function supplied by you when one of the pre-defined error occurs and pass you the "error" type, your code would then decide what to do. You can get a list of pre-defined errors at here:

http://www.essentialobjects.com/ViewDoc.aspx?t=JSDoc.Public.Handlers.clientside_error_handler.html

Hope this helps.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.