可以在服务器上显示文件类型图像 [英] Can a file type image be displayed on server

查看:67
本文介绍了可以在服务器上显示文件类型图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我创建了一个项目,我也有水晶报告。

我从前端输入图像,然后以二进制数据存储在数据库中。



这样做,否则我的图像没有显示在gridview或水晶报告中。



所以所有图像都是文件类型。



当我跑从我的本地机器localhost ... asp.net服务器,它显示所有的图像完美和运行良好。



但是,一旦我上传了我的所有文件服务器托管,



我的项目正在运行,但文件类型二进制数据中的图像未显示在gridview中



托管网站说图像应该转换为.jpg或.png



但是它在我的localhost服务器上工作,那么为什么这些图像没有显示在他们的托管服务器?



有人可以告诉我吗?因为我的网站已经在线,这些都是错误来了



谢谢

Sudeshna

Hello

I have created a project where I have crystal reports also.
I enter images from front end side and it gets stored in database in binary data.

This is done otherwise my images werent getting displayed in gridview or crystal report.

So all the images are of file type.

When i run from my local machine localhost...asp.net server, its showing all the images perfectly and running fine.

But as soon as I have uploaded all my files in server hosting,

My project is running but the images in file type binary data are not showing in gridview

The hosting website saying that the images should be converted to .jpg or .png

But its working on my localhost server, then why those images are not displaying in their hosting server?

Can anyone please tell me? as my website is already in live and these are the errors coming

Thanks
Sudeshna

推荐答案

您的本地环境与您的托管环境不同。在本地环境中,您可以轻松添加或删除功能或功能。在您的托管环境中,您必须遵守其规则和政策条款。您必须遵守它们才能使用他们的系统来托管您的应用程序(即使您支付它们!)。



如果托管服务器团队要求您仅使用图像文件而不使用二进制数据。你需要这样做。在此上下文中没有其他选项可供您使用。 无论您在本地环境中创建哪种补丁



以下代码使用传递给响应的MIME类型将(有效!)二进制数据转换为文件。您将在响应中获得一个文件。试试这个,



Your local environment is not the same as your hosting environment. On your local environment you can easily add or remove features or functions. On your hosting environment you are bound to their rules and policy terms. You have to abide them in order to use their system to host your application (even though you pay them!).

If hosting server team asks you to use only files for images and not binary data for them. You are required to do so. There is no other option for you to use in this context. No matter what other patch you can create on your local environment.

The following code converts the (valid!) binary data to a file, using the MIME type being passed to the response. You will get a file in the response. Try this,

Response.ContentType = file.MimeType; // or even plain image MIME as string
Response.BinaryWrite((byte[])file.FileContent);





您可以单独编写此代码ASP.NET服务器端文件。然后,您可以执行代码以获取可在进程中用于进一步处理的图像。



有关此主题的更多信息,请阅读: http://www.mikesdotnetting.com/article/148/save-and-retrieve-files-from-a-sql-server-ce -database-with-webmatrix [ ^ ]


这篇关于可以在服务器上显示文件类型图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆