I am using AsyncFileUpload (AJAX Toolkit) to upload images. I have a button that handles image resizing. This has been working fine for some time, but nothing more ...
protected void BtnUploadImage_Click(object sender, EventArgs e) { var imageFileNameRegEx = new Regex(@"(.*?)\.(jpg|jpeg|png|gif)$", RegexOptions.IgnoreCase); if (!AsyncFileUpload1.HasFile || !imageFileNameRegEx.IsMatch(AsyncFileUpload1.FileName)) { AsyncFileUpload1.FailedValidation = true; ErrorLabel.Visible = true; return; } ErrorLabel.Visible = false; var file = AsyncFileUpload1.PostedFile.InputStream; var img = Image.FromStream(file, false, false); ... }
Another thing that I find strange: if I try an image smaller than 80 kB, it will work.!
We tried to restart the server, but no changes. The same code works fine on my machine. (heard that before ?? :))
I also tried to save the file on the server and then get the file through Image.FromFile (), but then I get "Can't access the private file."
How to resolve this?
c # upload image asp.net-ajax ajaxcontroltoolkit
Thomas sandberg
source share