| Author: Raju.M 05 Sep 2008 | Member Level: Gold | Rating: Points: 2 |
it didnot work on Mozilla. becoz Mozilla return only the filename.extention for example if the upload file name is test.jpg,
IE returns file name with its location like C:\\test.jpg but Mozilla return test.jpg only. you can chang this by System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName).ToLower(); its returns full path. u can change ur code like this
if (fileUploadID.HasFile) { string fname = System.IO.Path.GetFileName(fileUploadID.PostedFile.FileName).ToLower();
System.Drawing.Image img1; img1 = System.Drawing.Image.FromFile(fname); int width = Convert.ToInt32(img1.Width); int height = Convert.ToInt32(img1.Height); if (width <= 600 && height <= 400) { lblerror.Text = "Image size is allowed"; } else { lblerror.Text = "Image size is not allowed"; } }
|
| Author: prasanthkumar 06 Sep 2008 | Member Level: Gold | Rating: Points: 0 |
Thanks
|
| Author: prasanthkumar 06 Sep 2008 | Member Level: Gold | Rating: Points: 1 |
i ve tried your code,still it didnt work
|
| Author: Raju.M 07 Sep 2008 | Member Level: Gold | Rating: Points: 6 |
sorry i didnt check ur reply. this is working code.
if (FileUpload1.HasFile) { byte[] byteArray=FileUpload1.FileBytes; System.IO.MemoryStream mm = new System.IO.MemoryStream(); mm.Write(byteArray, 0, byteArray.Length); System.Drawing.Image img1; img1 = System.Drawing.Image.FromStream(mm); int width = Convert.ToInt32(img1.Width); int height = Convert.ToInt32(img1.Height); if (width <= 600 && height <= 400) { lblerror.Text = "Image size is allowed"; } else { lblerror.Text = "Image size is not allowed"; } mm.Dispose(); }
|
| Author: prasanthkumar 08 Sep 2008 | Member Level: Gold | Rating: Points: 1 |
thanks, its a great help .at the rt time
|