System.Drawing.Image.FromStream()方法中的“参数无效”exception
我在网站上的Image.FromStream方法遇到了困难。 以下代码在我的计算机上运行良好。 但是当我将它上传到测试服务器时,它总是给我“参数无效”exception。
if (!afuImageFile.IsUploading && afuImageFile.HasFile) { System.Drawing.Image imgFile = System.Drawing.Image.FromStream(afuImageFile.FileContent); }
afuImageFile
是Ajax工具包中的AsynFileUploader
控件。 afuImageFile.FileContent
是一个HttpInputStream
。 我想我需要为某个文件夹添加一些权限。 谁能帮我?
请确保将FileContent
流的位置设置为0。
否则,您可能希望通过更改以下呼叫来停用图像validation:
System.Drawing.Image imgFile = System.Drawing.Image.FromStream(afuImageFile.FileContent);
至:
System.Drawing.Image imgFile = System.Drawing.Image.FromStream(afuImageFile.FileContent, true, false);
请参阅Image.FromStream
以检查其他重载。