c# - Validate uploaded file as image and then get the dimensions of it -
i want upload image file ftp server, have asyncfileupload
control on asp.net page. using following code type of asyncfileupload1.postedfile
, trying dimensions of having no luck far.
string ctype =asyncfu.postedfile.contenttype; if (ctype.contains("image")) { stream ipstream = asyncfu.postedfile.inputstream; image img = system.drawing.image.fromstream(ipstream); //error comes here, can't think work around this. int w = img.physicaldimension.width; int h = img.physicaldimension.height; }
as can see, errors message says cannot convert system.drawing.image
system.web.ui.webcontrols.image
. understand error, cannot think work around this.
i have asyncfileupload
control unknown file uploaded, saved ftp server if image file.
any suggestions?
try :
stream ipstream = fuattachment.postedfile.inputstream; using (var image = system.drawing.image.fromstream(ipstream)) { float w = image.physicaldimension.width; float h = image.physicaldimension.height; }
Comments
Post a Comment