c# - How to set max FileSize of uploaded file with if-statement? -


i created <asp:fileupload id="fileuploadpassfoto"> on webpage. (asp.net , c#)

i want check if uploaded file(image) bigger 6000kb. if true, file wont accepted , error message displayed. stored uploaded file following: (code behind)

system.drawing.image photo = system.drawing.image.fromstream(fileuploadpassfoto.postedfile.inputstream); 

now want check if image bigger 6000kb.

it works photo.size > size(6000kb).

any suggestions?

you can check this:

decimal size = math.round(((decimal)fileuploadpassfoto.postedfile.contentlength / (decimal)1024), 2);     if(size > 6000)     {        // size greater 6000kb      } 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -