Click here to Skip to main content
11,484,752 members (73,702 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
I want to upload fix Size of image in the database.or resize Image on the time of uploading.plz help me
Posted 15-Jan-13 19:57pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try the following :-

string[] sizes = { "B", "KB", "MB", "GB" };
double len = new FileInfo(filename).Length;
int order = 0;
while (len >= 1024 && order + 1 < sizes.Length) {
    order++;
    len = len/1024;
}


string result = String.Format("{0: 0.##} {1}", len, sizes[order]);
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I implemented once validation on size while uploading the image, I used a HTTPHandler to avoid postback.

But your requirement seems different, you want to resize if it not of required size. You can follow the below link



http://stackoverflow.com/questions/254419/asp-net-image-uploading-with-resizing[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 190
1 Sergey Alexandrovich Kryukov 160
2 Raje_ 155
3 OriginalGriff 137
4 Mehdi Gholam 130
0 Sergey Alexandrovich Kryukov 8,494
1 OriginalGriff 7,948
2 Sascha Lefèvre 3,199
3 Maciej Los 2,681
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 16 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100