如何将附件转换为图像数据类型 [英] How to Convert attachments to image data type

查看:104
本文介绍了如何将附件转换为图像数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在asp.net中有一个要求,即从文件上传控制我们必须选择任何类型的附件(.doc,pdf,.jpeg ......)然后我们要转换成sql server图像数据类型然后我们要保存在SQL Server数据库中。



请帮忙!!!



谢谢,

Codehub。

Hi,

I have one requirement in asp.net i.e. From File upload control we have to select any type of attachment(.doc,pdf,.jpeg......) then we have to convert into sql server image data type then we have to save in SQL Server database.

Please help!!!

Thanks,
Codehub.

推荐答案

你无法转换对图像的任何类型的附件 - 您需要一种可以阅读并处理成图像的附件类型,这意味着拥有一个能够应对数据格式的应用程序。例如,如果客户端上载Word文件,则服务器必须具有可以读取文件的Word(或类似程序)才能理解它 - 并且该程序必须具有从文档生成图像的功能。并非所有人都这样做。



大多数情况下,用户上传的内容无关紧要:只需将其存储在SQL中(或存储在文件中并将路径存储在SQL中)和让他再次下载。想一想:如果他上传了一个2小时的视频文件,如果你生成它,你应该使用哪个帧?
You can't convert "any type of attachment" to an image - you need an attachment type that you can read and process into an image, which means having an application that can cope with the data format as a minimum. For example, if the client uploads a Word file your server must have Word (or a similar program) that can read the file in order to understand it - and that program must have the facility to produce an image from the document. Not all do.

Most of the time, what the user uploads is irrelevant: just store it in SQL (or in a file and store the path in SQL) and allow him to download it again. Think about it: if he uploads a 2 hour video file, which frame should you use for the image if you generate it?


http://www.dotnetgallery.com/kb/resource21-How-to -store-and-retrieve-images-from-SQL-server-database-using-aspnet.aspx [ ^ ]

这可能是帮助
http://www.dotnetgallery.com/kb/resource21-How-to-store-and-retrieve-images-from-SQL-server-database-using-aspnet.aspx[^]
This may help


您不能将文件更改为图像,但要保存在SQL中,您可以将文件转换为字符串然后保存。请参阅以下链接

http://stackoverflow.com/questions/ 6850850 / reading-file-content-to-string [ ^ ]
you cannot change file into image but to save in SQL you could convert the file into string and then save it. See the below link
http://stackoverflow.com/questions/6850850/reading-file-content-to-string[^]


这篇关于如何将附件转换为图像数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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