"参数无效"从System.Drawing.Image.FromStream异常()方法 [英] "Parameter is not valid" exception from System.Drawing.Image.FromStream() method
问题描述
我有一个困难时期,在我的网站上Image.FromStream方法。下面的code完美的作品在我的电脑上。但是,当我上传到测试服务器,它总是给我参数无效的异常。
I got a hard time with the Image.FromStream method in my website. The code below works perfect on my computer. But when I uploaded it to the test server, it always gives me "Parameter not valid" exception.
if (!afuImageFile.IsUploading && afuImageFile.HasFile)
{
System.Drawing.Image imgFile = System.Drawing.Image.FromStream(afuImageFile.FileContent);
}
在Ajax工具包的 afuImageFile
是 AsynFileUploader
控制。 afuImageFile.FileContent
是 HttpInputStream
。我想我需要一些权限添加到某个文件夹。谁能帮我?
the afuImageFile
is an AsynFileUploader
control in Ajax Tool Kits. afuImageFile.FileContent
is a HttpInputStream
. I guess I need to add some permission to some folder. Can anyone help me?
推荐答案
请确保您的 FileContent
流作为其位置设置为0。
Please ensure that your FileContent
stream as its position set to 0.
否则,你可能要通过更改电话停用图像验证:
Otherwise, you might want to deactivate image validation by changing the call from:
System.Drawing.Image imgFile = System.Drawing.Image.FromStream(afuImageFile.FileContent);
到
System.Drawing.Image imgFile = System.Drawing.Image.FromStream(afuImageFile.FileContent, true, false);
请参阅 图像。 FromStream
以检查其他重载。
See Image.FromStream
to check on the other overloads.
这篇关于"参数无效"从System.Drawing.Image.FromStream异常()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!