使用asp.net中的httpfilecollection显示图像而不保存到文件夹

问题描述:

朋友们,我有一个Web应用程序,其中一次使用httpFileCollection上传多个图像.它的工作正常,但我将图像保存在文件夹中以显示上载图像的预览.这里是显示图像的任何方式,而无需将其保存到文件夹中.

如果有人对此有任何想法,请帮我.

在此先感谢
Parveen Rathi

Hi Friends, I have a web application in which I am uploading multiple images at one time using httpFileCollection. Its working fine, but I am saving the the images in folder to show the preview of the uploaded images. Is here any way to display the image without save it to the folder.

Pleas help me if anybody have some idea about it.

Thanks in advance
Parveen Rathi

将文件集合转换为内存中"图像并显示(不将其复制到文件夹中).
例如
Convert the file collection to an ''in memory'' image and display it (without copying it to a folder).
E.g.
HttpPostedFile file = context.Request.Files[0];
                    byte[] buffer = new byte[file.ContentLength];
                    file.InputStream.Read(buffer, 0, file.ContentLength);

BinaryReader b = new BinaryReader(file.InputStream);
byte[] binData = b.ReadBytes(file.InputStream.Length);