画像ファイルをFTPサーバーにアップロードしたいので、AsyncFileUpload
asp.netページを制御しています。次のコードを使用して型をAsyncFileUpload1.PostedFile
取得し、その次元を取得しようとしていますが、これまでのところ運がありません。
string cType =asyncFU.PostedFile.ContentType;
if (cType.Contains("image"))
{
Stream ipStream = asyncFU.PostedFile.InputStream;
Image img = System.Drawing.Image.FromStream(ipStream); //ERROR comes here, I can't think the work around this.
int w = img.PhysicalDimension.Width;
int h = img.PhysicalDimension.Height;
}
System.Drawing.Image
ご覧のとおり、 からに変換できないというエラー メッセージが表示されSystem.Web.UI.WebControls.Image
ます。エラーは理解できますが、これを回避する方法は考えられません。
不明なファイルがアップロードされる場所をAsyncFileUpload
制御できますが、画像ファイルの場合のみ FTP サーバーに保存されます。
助言がありますか?