Welcome Guest Search | Active Topics | Sign In | Register

AjaxUploader - PostedFilesPlaceHolder question Options
ljubok
Posted: Monday, March 16, 2009 11:49:23 AM
Rank: Newbie
Groups: Member

Joined: 3/16/2009
Posts: 9
Hello,

Is it possible to display only last uploaded file in PostedFilesPlaceHolder, and how?
I am using the control with AutoUpload="true", but would like to display only the last file that has been uploaded. Customizing label format (getting rid of the checkbox) would also be useful...


Thanks in advance
eo_support
Posted: Monday, March 16, 2009 11:55:16 AM
Rank: Administration
Groups: Administration

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

There is no need to use PostedFilesPlaceHolder to display the last uploaded file. Just put a Label in your page (you do not need to put it inside the uploader's LayoutTemplate) and handle the Uploader's FileUploaded event, then update the Label whatever way you wanted based on the event arguments, which contains information about the uploaded files. Once you get this working, you would simply remove PostedFilesPlaceHolder from your LayoutTemplate.

Please let us know if this makes sense to you.

Thanks!
ljubok
Posted: Monday, March 16, 2009 12:50:04 PM
Rank: Newbie
Groups: Member

Joined: 3/16/2009
Posts: 9
Thanks for the quick reply, that does the job.

I'll get back to you as soon as I run into another problem :)


EDIT:
Is there a way to catch FileUploaded event on a client via javascript?
eo_support
Posted: Monday, March 16, 2009 1:09:01 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
No. The closest you can have is this:

http://doc.essentialobjects.com/library/1/eo.web.ajaxuploader.clientsideondone.aspx

Also check other ClientSideOnXXX properties on the uploader to see if any of them would be useful to you. If you are not familiar with our client side interface, you will want to go over this topic first:

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

Thanks!
ljubok
Posted: Thursday, March 19, 2009 11:35:42 AM
Rank: Newbie
Groups: Member

Joined: 3/16/2009
Posts: 9
Quick question:

Can I stop uploader from making a postback if I catch error on client?
For example, I don't want to make postback after catching "max_size_exceeded" error on client.

Thanks!
eo_support
Posted: Thursday, March 19, 2009 12:23:50 PM
Rank: Administration
Groups: Administration

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

You do not need to stop the uploader to make a post back when an error occurs. The uploading process is automatically stopped.

If you are interested in perform additional actions when an error occurs, you can handle this client side event:

http://doc.essentialobjects.com/library/1/eo.web.control.clientsideonerror.aspx

You would check the arguments to determine the type of errors and then do whatever you would like to or would not like to do.

Thanks!
ljubok
Posted: Thursday, March 19, 2009 12:27:19 PM
Rank: Newbie
Groups: Member

Joined: 3/16/2009
Posts: 9
Hi,

Sorry about this stupid question, I got it figured out. I had a line in ClientSiteOnCancel that caused postback...

I actually handle errors just like you described it...

Thanks againfor very quick reply!
ljubok
Posted: Friday, March 20, 2009 9:13:18 AM
Rank: Newbie
Groups: Member

Joined: 3/16/2009
Posts: 9
eo_support wrote:
No. The closest you can have is this:

http://doc.essentialobjects.com/library/1/eo.web.ajaxuploader.clientsideondone.aspx

Also check other ClientSideOnXXX properties on the uploader to see if any of them would be useful to you. If you are not familiar with our client side interface, you will want to go over this topic first:

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

Thanks!


Back to this question.

OK, so I'm catching ClientSideOnDone event. What I'd like to do is access some information about the file that has been uploaded (e.g. name, size, etc).

I tried using uploader's getPostedFiles method since I noticed that objects returned via this method have member methods such as getClientFileName. However, these methods do not return desired values....

So my question is: Can I access information about uploaded files on the clent side, after the upload is done, and how do I do it?

eo_support
Posted: Friday, March 20, 2009 9:39:46 AM
Rank: Administration
Groups: Administration

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

Try to use setTimeout to delay call to getPostedFiles. For example, instead of calling:

Code: JavaScript
alert(uploader1.getPostedFiles().length);


Try to do:

Code: JavaScript
setTimeout(
    function()
    {
        alert(uploader1.getPostedFiles().length);
    }, 10);


The reason is the posted file list has not been set yet when ClientSideOnDone is called. So once you delay the call, you should get the correct value.

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.