Welcome Guest Search | Active Topics | Sign In | Register

AjaxUploader - OnFileUploaded Options
ZD
Posted: Monday, March 24, 2008 4:27:48 AM
Rank: Newbie
Groups: Member

Joined: 3/24/2008
Posts: 7
Hi everybody,
when OnFileUploaded event fires, I want to post the uploaded files to FTP. I wrote a function, which did that for files uploaded by asp:fileuploader.
But the event won't fire!
And I don't exactly understand how to deal with clientside_error_handler Event Handler
10x for your replies.
ZD
Posted: Monday, March 24, 2008 4:41:54 AM
Rank: Newbie
Groups: Member

Joined: 3/24/2008
Posts: 7
And how do I rename the file before it's saved to FinalFileLocation?
eo_support
Posted: Monday, March 24, 2008 6:53:45 AM
Rank: Administration
Groups: Administration

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

As for why the event is not firing, please read our reply to this post:

http://www.essentialobjects.com/Forum/Default.aspx?g=posts&t=1233

Once you set FinalFileLocation, the uploader automatically rename the file for you. If you wish to rename (or move) the file by yourself, you don't use FinalFileLocation. You would just handle FileUploaded event and do whatever you want with the uploaded files.

Thanks
ZD
Posted: Monday, March 24, 2008 7:13:38 AM
Rank: Newbie
Groups: Member

Joined: 3/24/2008
Posts: 7
Thanks, as for the event - I went over some older posts here and found your reply to somebody else, so it's fixed, thanks.
the rename thing - suppose I save a file from my computer called lake.*, and I set the templocation to be ~/TmpFile, so besides the history and status files it saves a GUID-named datafile, while I need it as MY_GUID.*.
Help please!
eo_support
Posted: Monday, March 24, 2008 7:21:44 AM
Rank: Administration
Groups: Administration

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

Inside your FileUploaded event handler, you would first get a list of AJAXPostedFile objects through the uploader's PostedFiles property, you will get the temp file via this property:

http://www.essentialobjects.com/ViewDoc.aspx?t=EO.Web.AJAXPostedFile.TempFileName.html

And then you would just call File.Move to rename it.

Thanks
ZD
Posted: Monday, March 24, 2008 7:26:50 AM
Rank: Newbie
Groups: Member

Joined: 3/24/2008
Posts: 7
10x, I've already tried that :
Code: C#
filename = auVideo.PostedFiles[0].TempFileName.Substring(0, auVideo.PostedFiles[0].ClientFileName.LastIndexOf("."));
                System.IO.FileInfo fi = new System.IO.FileInfo(auVideo.PostedFiles[0].TempFileName);
                fi.MoveTo(auVideo.PostedFiles[0].TempFileName.Replace(filename, Session["FileGUID"].ToString()));

And it won't help.
I get files with .data extensions. Am I supposed to rename the extensions back too or is there something that can be defined in the control to keep the original exception?
eo_support
Posted: Monday, March 24, 2008 7:33:57 AM
Rank: Administration
Groups: Administration

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

If you are interested in getting it back to the original extension, you will need to use this property:

http://www.essentialobjects.com/ViewDoc.aspx?t=EO.Web.AJAXPostedFile.ClientFileName.html

A lot of stuff is already in the documentation. So you might want to go over that. As for generic programming like renaming the file, your code appears to be totally wrong but unfortunately it would not be a topic that our support would cover. So you may wish to get somebody around you to help you on that. Sorry about that!

Thanks
ZD
Posted: Monday, March 24, 2008 8:43:02 AM
Rank: Newbie
Groups: Member

Joined: 3/24/2008
Posts: 7
I know you aren't there to fix my code, but I'm trying to figure out how it works, and the documentation isn't helping. Is the .data extension the default?
eo_support
Posted: Monday, March 24, 2008 9:13:59 AM
Rank: Administration
Groups: Administration

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

The AJAXUploader does two things for you:

1. Upload the file to the server;
2. Give you information about the file being uploaded;

Here is the most important information the AJAXUploader gives to you:

1. A temp file name (you should not care how the temp file name looks like, for example, whether it has a .data extension does not matter to you). This is the file with the same content as the file user uploaded;

2. The real client side name. For example, if you have uploaded file "something.zip". You will get that from the ClientFileName property;

Now it's your job to move the temp file to wherever you would like. You can:

1. Move it to fixed file name, for example, "c:\myfiles\1.abc";
2. You may also want to use the same file extension as the real client side name while you move, for example, move it to "c:\myfiles\1.zip";
3. You may want to use both the same file name and extension as the real client side name, for example, move it to "c:\myfiles\something.zip".

The point is you are free to do whatever you want with the information you have.

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.