Welcome Guest Search | Active Topics | Sign In | Register

AJAXUploader: Get the client file name Options
John Fotiadis
Posted: Thursday, May 28, 2009 11:00:04 AM
Rank: Newbie
Groups: Member

Joined: 11/24/2008
Posts: 5
Hi all,

I am using the AJAXUploader in my ASP.NET application and works fine. The only issue I have is that I want to get the client file name in the ClientSideOnChange event and put it in a textbox. Can you please provide me a simple portion of Javascript code to acheive this ?

I use the following code but with no success

Code: JavaScript
function UploaderChange()
	{
	   
	    var uploader = $find("AJAXUploader1");
	    var PostedFiles = uploader.getPostedFiles();
        for (var i = 0; PostedFiles.length(); i++)
        {
            PostedFile = PostedFiles[i];
            UploaderFileName.innerText = PostedFile.getClientFileName();
            alert(UploaderFileName.innerText);
            UploaderFileIdentifier.innerText = PostedFile.TempFileName;
        }
	}
Thanks

John
eo_support
Posted: Thursday, May 28, 2009 11:41:06 AM
Rank: Administration
Groups: Administration

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

There are a few places need to be changed in your code:

1. I am not sure whether you have implemented $find by yourself so that it calls eo_GetObject function or not. Our object is not a DOM element. So you can not use document.getElementById. In general, you should always call eo_GetObject to get an EO.Web client side JavaScript object. You can see here for more details:

http://doc.essentialobjects.com/library/1/clientapi_howto.aspx

2. Your for loop syntax is wrong. It should be "for (var i = 0; i < PostedFiles.length; i++)". Note that such generic coding error is actually outside of the scope of our support. So you may want to enable JavaScript debugging on your browser so that you will be able to catch such errors easily;

3. PostedFile.getClientFileName() is correct but PostedFile.TempFileName is wrong. TempFileName file name is never transferred to the client side for security reasons. As such it is not possible for you to get TempFileName on the client side directly from the uploader.

Hope this helps. Please feel free to let us know if you have any more questions.

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.