图像保存到文件系统使用MVC3 [英] Saving image to the filesystem using mvc3

查看:121
本文介绍了图像保存到文件系统使用MVC3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些简单的实体现在需要有一个配置文件的图像。什么是做到这一点的正确方法?因此,它是1对1的关系,一个图像仅涉及一个实体,反之亦然。此图片应该通过表单上载与插入相关实体在一起。

I have some simple entity which now needs to have a Profile image. What is the proper way to do this? So, it is 1 to 1 relationship, one image is related only to one entity and vice versa. This image should be uploaded through webform together with inserting related entity.

所以,我指着使用文件系统存储图像,并坚持只路径图像到数据库我不得不问,如果有人有任何教程或链接提供,或code的例子。

So, as I'm pointed to use filesystem to store image and to persisted only path image into db I have to ask if someone have any tutorial or link to provide, or code example.

感谢

推荐答案

我坚持图像源本身使用实体框架的数据库,我makesure我inlcude在数据库中的以下内容:

I persist the IMAGE source itself to the database using Entity Framework, and i makesure i inlcude the following in the database:


  • 创建日期

  • 文件类型(内容类型)

  • 源(二进制)

  • 文件名

  • 文件大小

  • 高度

  • 宽度

我使用的字节流/ BinaryReaders加载它。我的code是在这里:

I load it using byte streams/BinaryReaders. My Code is here:

http://garfbradazweb.word$p$pss.com/2011/08/16/mvc-3-upload-sql-server-entity-framework/

全系列教程是在这里:
HTTP://garfbradazweb.word$p$pss.com/welcome -to-MY-ancedotes /#

The full tutorial series is here: http://garfbradazweb.wordpress.com/welcome-to-my-ancedotes/#

在关系方面,我有以下几点:

In terms of relationships, i have the following:

媒体表 - 存储的所有图像,包括上述提到的列。您可能需要与其他表的图像。关键是uniquieid(SQL)该C#类型是GUID。

Media Table - Stores all the images and includes the above columns mentioned. You may need images related to other tables. The key is a uniquieid (SQL) for which the C# Type is Guid.

个人资料表 - 存储我的用户的个人资料。在这里,我有一个ImageId这是档案行和图像之间的OME一对一的关系。

Profile Table - Stores my Profile of the user. Here i have a ImageId which is a ome-to-one relationship between the Profile row and the Image.

我已经写了MVCImage应用程序,它展示了如何在这里使用这样的:

I have written a MVCImage app which shows you how to use this here:

HTTP://mvcimage.$c$cplex.com/
让我知道这是OK,或者您需要code的例子。

http://mvcimage.codeplex.com/ Let me know if this is OK or if you need code examples.

这篇关于图像保存到文件系统使用MVC3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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