English 中文(简体)
C# 图像上载荷,使用文件上载
原标题:C# Image uploading using FileUpload
  • 时间:2012-01-13 15:16:45
  •  标签:
  • c#
  • image

我发现以下法典,但无法理解我通过<代码>应该通过什么。 ∗∗∗∗∗∗∗。

我需要一个文件上载工具,把图像上载到系统,然后将其传送到<代码>。 图1

参考,我的法典

public string ImageToBase64(Image image, System.Drawing.Imaging.ImageFormat format)
    {
        using (MemoryStream ms = new MemoryStream())
        {
            image.Save(ms, format);
            byte[] imageBytes = ms.ToArray();
            string base64String = Convert.ToBase64String(imageBytes);
            return base64String;
        }
    }

我尝试了<代码>Image ToBase64(FileUpload)。 文件Bytes,“Image/PNG”,但我正在发现同义词。 我能对这一法典使用哪些正确的语气?

最佳回答

由于该功能涉及图像和图像表的类型,你正在通过斜线和插图。

你不需要奇迹,你只需要。

var base64String = Convert.ToBase64String(FileUpload.FileBytes);
问题回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...