3 Answers, 1 is accepted
0
Hello G,
Thank you for the interest in our RadUpload control.
Generally there are two parts that work together in the upload process: the RadUpload control (at client side) and the upload handler (at server side). You should decide where the check-code will reside - for example:
Sincerely yours,
Ivan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Thank you for the interest in our RadUpload control.
Generally there are two parts that work together in the upload process: the RadUpload control (at client side) and the upload handler (at server side). You should decide where the check-code will reside - for example:
- if you put the check-code at server side (in upload handler) you should return the MIME type as a custom parameter from the upload handler. More information you can find in the Returning custom data from the handler article.
- if you put the mine-check-code at the client side you should run it inside the FileUploaded event-handler. Note all the information about the uploaded file and the status of the upload itself are in the FileUploadedEventArgs argument (the second one), for example:
private void RadUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { if (e.HandlerData.IsSuccess) { ExploreMIME.GetType(e.SelectedFile.File); . . .
Sincerely yours,
Ivan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
KDL
Top achievements
Rank 1
answered on 17 Apr 2012, 01:33 AM
I know this is an old thread but I'm having the same problem. I need to know the MIME type of the file and this post indicates that it's available. The example given didn't work for me. I am able to pass values between the RadUpload control and the Handler without a problem, but I'm just not seeing how to get the mime type in the first place. Thanks!
0
Hello Kent,
The RadUpload control doesn't expose a method or property which can give you the MIME type, but you can create a custom method for finding the MIME type of a file based on its extension for example. You can have a look at this thread where different approaches, for getting the MIME type of a file, are discussed.
Regardless of the approach you choose for getting the MIME type, it would be best to place the logic on the server-side part of the RadUpload control. You can override the SaveChunkData method and as soon as the entire file is uploaded, implement a custom method to get its MIME type:
Then you can use the MIME type on the server or pass it to the client by overriding the GetAssociatedData() method. I attached a sample project to get you started, please give it a try and let me know if it helps.
Greetings,
Tina Stancheva
the Telerik team
The RadUpload control doesn't expose a method or property which can give you the MIME type, but you can create a custom method for finding the MIME type of a file based on its extension for example. You can have a look at this thread where different approaches, for getting the MIME type of a file, are discussed.
Regardless of the approach you choose for getting the MIME type, it would be best to place the logic on the server-side part of the RadUpload control. You can override the SaveChunkData method and as soon as the entire file is uploaded, implement a custom method to get its MIME type:
string
MIMEType;
public
override
bool
SaveChunkData(
string
filePath,
long
position,
byte
[] buffer,
int
contentLength,
out
int
savedBytes)
{
bool
result =
base
.SaveChunkData(filePath, position, buffer, contentLength,
out
savedBytes);
if
(
this
.IsFinalFileRequest())
{
FileInfo fi =
new
FileInfo(filePath);
MIMEType = GetMimeType(fi);
}
return
result;
}
Then you can use the MIME type on the server or pass it to the client by overriding the GetAssociatedData() method. I attached a sample project to get you started, please give it a try and let me know if it helps.
Greetings,
Tina Stancheva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>