与其他详细信息一起如何在asp.net mvc 4中的CRUD操作中包含图像? [英] Along with other Details how to include a image in CRUD operation in asp.net mvc 4 ?

查看:54
本文介绍了与其他详细信息一起如何在asp.net mvc 4中的CRUD操作中包含图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个小的crud应用程序,用户可以在其中输入名称,地址和其他详细信息,但我确实想要使用图像以及详细信息,以便用户可以更新他们的照片以及其他详细信息,所以我想知道如何在那里使用图像。

I have created a small crud application, where user can put names,addresses and other details but I do want to put an option to use image along with details,so that user can update their photo along with other details,so I want to know how to use an image there.

推荐答案

你好Umeshinator,



有两种方法您可以在MVC中实现使用图像,例如

i)将图像存储在服务器的某个位置,并在varchar列中保存用户详细信息数据的路径。



例如: - 将图像上传组件放到页面上,然后首先将其上传到服务器中的某个位置。然后获取该位置并将其保存到数据库表varchar列。检索时只检索路径并从同一位置显示图像。



在MVC中,你必须使用一些jQuery组件进行图像上传。



ii)使用数据类型图像将整个图像作为二进制数据保存到数据库中。





如果您已经在进行某些CRUD操作,那么您只需将图像存储在服务器位置并保存到数据库表的路径就很容易。





希望这可以作为您的提示,并且已经有一些帖子可能对您有所帮助。以下参考显示了asp.net以两种方式存储图像的示例。请参考,你可以得到一些想法。



参考: -

http://www.aspsnippets.com/Articles/Retrieve-images-using-a-file- path-in-database-in-ASPNet.aspx [ ^ ]



使用标记过程和C#.net从SQL Server中检索和检索图像 [ ^ ]



发布MVC: HTTP:// STAC koverflow.com/questions/16414074/mvc4-c-sharp-want-to-save-a-image-to-a-folder-and-saving-the-url-in-database [ ^ ]
Hi Umeshinator,

There are two ways you can achieve using image in MVC like
i) Store the image in some location at your sever and save its path for the user details data in a varchar column.

Ex :- Put a image upload component to your page and first upload it to a location in server. Then take that location and save it to database table varchar column. While retrieving just retrieve the path and show the image from same location.

In MVC you have to use some jQuery component for image upload.

ii) Save the whole image into database as a binary data using datatype 'Image'.


If you are already doing some CRUD operation it will be definitely easy for you to just store the image on server location and save the path to your database table.


Hope this will work as a hint for you and there is already some posts which might be of help for you. The below references show example for asp.net to store image in both way. Please refer and you can get some idea.

Reference :-
http://www.aspsnippets.com/Articles/Retrieve-images-using-a-file-path-stored-in-database-in-ASPNet.aspx[^]

Storing and Retrieving Images from SQL Server Using Strored Procedures and C#.net[^]

Post for MVC : http://stackoverflow.com/questions/16414074/mvc4-c-sharp-want-to-save-a-image-to-a-folder-and-saving-the-url-in-database[^]


1。将图像保存在服务器中的某个位置,并将图像名称的路径存储在数据库列中。

2.将图像保存在数据库中。
1. Save the image in a location in server and store the path with image name in database column.
2.save the image in database.


这篇关于与其他详细信息一起如何在asp.net mvc 4中的CRUD操作中包含图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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