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

RadAsync Upload temporary filename

3 Answers 204 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Lighthouse Developer
Top achievements
Rank 1
Lighthouse Developer asked on 05 Jul 2010, 11:06 AM
Hi,
Ι know that it has been asked many times,but is there a workaround to get the  the temporary file's name(not the filepath,only the filename) ?
I want to check the dimensions of the uploaded image after it has been uploaded.
Unfortunately the upload with full postback is not an option,because in my scenario the're mutliple radAsyncUpload controls in the same page.

3 Answers, 1 is accepted

Sort by
0
mastermehdi
Top achievements
Rank 2
answered on 05 Jul 2010, 07:12 PM

use somthing like this ror an asp:CustomValidator

    protected void csvView0DimensionBannerFile_ServerValidate(object sender, ServerValidateEventArgs args)
    {
        if (rauView0BannerFile.UploadedFiles.Count == 1 && ddlView0Dimensions.SelectedValue != "0")
        {
            if (rauView0BannerFile.UploadedFiles[0].ContentType.ToLower() == "image/gif" ||
                rauView0BannerFile.UploadedFiles[0].ContentType.ToLower() == "image/jpeg" ||
                rauView0BannerFile.UploadedFiles[0].ContentType.ToLower() == "image/png")
            {
                using (Stream fileStream = rauView0BannerFile.UploadedFiles[0].InputStream)
                {
                    System.Drawing.Image image = System.Drawing.Image.FromStream(fileStream);
                    if (image.Width.ToString() == 800 && image.Height.ToString() == 600)
                    {
                        args.IsValid = true;
                    }
                    else
                    {
                        args.IsValid = false;
                    }
                }
            }
        }
    } 

0
Lighthouse Developer
Top achievements
Rank 1
answered on 05 Jul 2010, 08:05 PM
Thank you very much for your help Mehdi,
but if Im right,the server validate method of the asp.validator is executed after page postback.
        As I mention in my first post,the full page postback is not an option in my scenario,because I want to have multiple RadAsyncUpload controls in my page.The postback caused from one RadAsyncUpload will "change" the rest of the upload controls and I want to avoid such behavior.

Thank you very much again
0
Accepted
Genady Sergeev
Telerik team
answered on 06 Jul 2010, 09:46 AM
Hello Lighthouse Developer,

The temporary filename is not available on the client due to security reasons. However, we have some good news from you. Starting from the upcoming Q2 release, one will be able to do such kind of validation at the handler and then return some custom result to the client (containing the result of the validation, for example). You can find sample demo demonstrating the approach here.

Sincerely yours,
Genady Sergeev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
AsyncUpload
Asked by
Lighthouse Developer
Top achievements
Rank 1
Answers by
mastermehdi
Top achievements
Rank 2
Lighthouse Developer
Top achievements
Rank 1
Genady Sergeev
Telerik team
Share this question
or