This is a migrated thread and some comments may be shown as answers.

Get File Extention and Size direct after selection of the file!!!

2 Answers 77 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Asa'ad
Top achievements
Rank 1
Asa'ad asked on 14 Sep 2011, 07:25 AM
Hi All,

I have a form with a RadGird that load a saved images files from the database....
all is ok...
The grid has the option of adding new one and edit the existing....

I have added TemplateColumns for the Image column, that has Edit and Insert Item templates....

In those template i added the RadUpload Control, to allow the user to select the file he wants to save to the database...

the grid and insert and the edit function all works ok....

But i need to show the the extention and size of the selected file to be saved before it is saved to the database and show them in read only textboxes also shown in the edit/insert form....

I can find this upload control in the grid itemcreated event and i added the an event handler of this upload control to handle the FileExists event and i added the function to be called when this event fires BUT this function nevers called!!!!

Here is my code in the grid item created event

MyUploadControl.FileExists += new 
Telerik.Web.UI.Upload.UploadedFileEventHandler(myFunction);
and this is the function defined to handle this event

Protected void myFunction(Object sender, 
Telerik.Web.UI.Upload.UploadedFileEventArgs e){  someLabel.Text = 
"my function is called";
}
my idea is to get the size and exetenstion of the selecetd file within this function and show them in the corresponding controls....

But this function never calls....


I don't know what i am missing????

Any help will be great....

Thanks
Asa'ad.....

2 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 14 Sep 2011, 01:23 PM
Hello Asa'ad,

The FileExists event is never raised because it is only called when the file could not be saved to a folder. You can use the ValidatingFile event as it is always raised when a file is uploaded.

I hope that helps.
0
Peter Filipov
Telerik team
answered on 16 Sep 2011, 08:35 AM
Hello Kevin,

To get the file's size, the file should be uploaded to the server(RadUpload is using a standard input type='file' control and it is not possible to get the file's size on the client-side). It is possible to validate file's extension on the client-side. Please review the following help article.

In case you want to check the file's size and extension on the client, please use RadAsyncUpload control. Probably the following demos will be helpful for you - Validation, RadAsyncUpload in RadGrid.

Greetings,
Peter Filipov
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
Tags
Upload (Obsolete)
Asked by
Asa'ad
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Peter Filipov
Telerik team
Share this question
or