问题描述
能否请您在(c#网络开发)中给我适当的代码,以上传所有类型的图像(.jpg,.gif,.png,bmp等.)
我收到了代码,但只上传了jpg ..
格式的图像我想知道,上传除jpg以外的其他格式的图片有什么问题吗?
而且我还想要不允许上传任何重复图像的代码.
此外,我将把该图像名称存储在数据库中,并且当我上载图像时,我想将其显示在图像控件上
但是因为我仅上传单个图像,所以我不想使用任何完全数据绑定的控件,例如(Gridview,repeater或任何其他控件)..
怎么做??
谢谢:)
can you please give me a proper code in (c# web devolpment) to upload all types of images(.jpg,.gif,.png,bmp etc..)
i got the code but it only uploads images of the format jpg..
i want to know, is there any problem to upload images of the format other than jpg??
and also i want the code which would not allow to upload any duplicate image..
moreover i will store that image name on database and when i would upload the image, i would like to show it on an image control
but because i am uploading only single image so i do not want to use any fully data bound controls like (Gridview,repeater or any other)..
how to do it??
thanks :)
推荐答案
我得到了代码,但只有上传jpg ..
i got the code but it only uploads images of the format jpg..
格式的图像
那是不可能的.网络应用程序通过不在乎要处理哪种文件的控件来上传您喜欢的任何文件.这是HTML中的唯一选项,因此也是ASP.NET中的唯一选项.
使用ASP.NET标记可让人们知道您是否正在编写Web应用程序.
That is impossible. A web app uploads any file you like, through a control that doesn''t care what sort of file it is dealing with. That''s the only option in HTML, and therefore in ASP.NET.
Use the ASP.NET tag to let people know if you''re writing a web app.
而且我还希望该代码不允许上传任何重复的图像..
and also i want the code which would not allow to upload any duplicate image..
您可以检查是否使用了相同的文件名,但无法轻易分辨出两个图像是否完全相同,也就是说,对于较大的图像,没有一点代码也没有一点时间.
you can check if the same filename has been used, but you can''t easily tell if two images are exactly the same image, that is, not without a bit of code and a bit of time for larger images.
此外,我会将图像名称存储在数据库中,并且当我上载图像时,我希望将其显示在图像控件上
moreover i will store that image name on database and when i would upload the image, i would like to show it on an image control
好,那很容易
OK, that''s easy
但是因为我仅上传单个图像,所以我不想使用任何完全数据绑定的控件,例如(Gridview,repeater或任何其他).
but because i am uploading only single image so i do not want to use any fully data bound controls like (Gridview,repeater or any other)..
要在数据绑定控件中显示图像,请为显示img标签或asp:Image标签的列创建模板,并将图像路径绑定到控件.如果您只想显示单个图像,则只需一个img或asp:Image控件,然后将其绑定到您必须使用的单个路径上,实际上该任务没有什么区别,唯一的区别是添加了一个步骤,使其可以通过数据集处理许多图像.
顺便说一句,我非常感谢您声明您正在编写一个Web应用程序,并使用真实的英语提出您的问题.请只使用ASP.NET标记以及C#,这样,如果人们正在过滤要回答的问题,他们就会找到您的问题.我问这个问题仅是出于您的利益.
To show images in a data bound control, you''d create a template for a column that shows an img tag, or an asp:Image tag, and binds the image path to the control. If you only want to show a single image, you''d just have a single img or asp:Image control, and bind that to the single path that you have to work with, there''s literally no difference in the task, the only difference is adding a step to make it work with many images through a dataset.
Just to add, I appreciate you stating that you''re writing a web app, and using real English to ask your question. Please just use the ASP.NET tag as well as C#, so that if people are filtering for questions to answer, they will find yours. It''s really only for your benefit that I ask this.
这篇关于如何上传所有类型的图片?(.jpg,.gif,.png,bmp等.)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!