|
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.
|
|
Rank: Newbie Groups: Member
Joined: 3/24/2008 Posts: 7
|
And how do I rename the file before it's saved to FinalFileLocation?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
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=1233Once 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
|
|
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!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
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.htmlAnd then you would just call File.Move to rename it. Thanks
|
|
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?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
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.htmlA 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
|
|
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?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
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
|
|