参数无效。 - 只发生在 Gif 中

发布于 2024-10-05 15:53:34 字数 460 浏览 3 评论 0原文

我有一些代码允许用户将图像上传到我的服务器。

它在几个月内运行良好,仅接受 PNG 和 JPEG,因为最初它用于照片。

现在我想用来上传横幅,所以我需要接受 gif,但每次我尝试上传 gif 时都会收到此错误。

"Parameter is not valid."

在这段代码上,

Bitmap myBitmap = new Bitmap(HttpContext.Current.Server.MapPath(_SavePath + imageFileName));

奇怪的是它对 PNG 和 JPEG 工作得很好,但对 GIF 却一点也不工作,

我已经在谷歌上搜索了几个小时,从我得到的信息来看,这个错误似乎很痛苦,而且不描述真正的问题。

有人可以帮忙吗?

谢谢特鲁吉利

I have some code that will allow a user to upload an image to my server.

its worked fine for months accepting just PNG and JPEG's, as initially it was used for photographs.

now I want uses to upload banners, so I need to accept gifs, but every time I try and upload a gif I get this error.

"Parameter is not valid."

on this bit of code

Bitmap myBitmap = new Bitmap(HttpContext.Current.Server.MapPath(_SavePath + imageFileName));

the weird thing is it works fine with PNG's and JPEG's bit not at all with GIF's

I've been googling for a few hours now and from what i get, it seems that this error is a pain and doesn't describe the real issue.

can anyone help ?

Thanks

Truegilly

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爺獨霸怡葒院 2024-10-12 15:53:36

抛出的是哪种方法? Bitmap的构造函数还是MapPath?

如果是位图:

您确定 GIF 有效吗?即使它不是 100% 符合规范,其他程序也可能能够读取它,但也许位图更加挑剔。

您是否尝试过许多不同的 GIF 文件并遇到此问题?

如果 MapPath:

GIF 的名称在传递到 MapPath 后是否无效?检查看看它是什么。

如果 GIF 可能不太好——您可以尝试我公司的产品,DotImage Photo,它是免费的。它有一个名为 AtalaImage 的类,您可以像 Bitmap 一样使用它,并且它可以读取可能不合规格的图像。

Which method is throwing? Bitmap's constructor or MapPath?

If Bitmap:

Are you sure the GIF is valid? Other programs might be able to read it even if it's not 100% to spec, but perhaps Bitmap is being more picky.

Have you tried many different GIF files and had this problem?

If MapPath:

Is the name of the GIF not valid once it gets passed to MapPath? Check to see what it is.

If the GIF is possibly not a good one -- you can try my company's product, DotImage Photo, which is free. It's got a class called AtalaImage that you can use like Bitmap and it can read images that might be off-spec.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文