本文介绍了抢先形象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在尝试上传图片.我已将上传控件添加为网页
Hi all,
I am trying to upload an image.I haev added an upload control to my web page as
Upload front Image<input id="File1"
style="Z-INDEX: 100; LEFT: 300px; WIDTH: 288px; POSITION: absolute; TOP: 120px; HEIGHT: 22px"
type="file" size="28" name="Upload" runat="server" >
<div>
<asp:Button ID="btnPreview" runat="server" Text="Preview Images"
onclick="btnPreview_Click" />
</div>
<asp:Panel id="Panel1" runat="server" Height="1000px" Width="800px" Visible = "true">
<asp:Image ID="Image6" runat="server" />
</asp:Panel>
当用户单击预览按钮时,我想在图像控件中显示选定的图像.
我在 File1.Value 中获取上载文件的路径,并将其分配为ImageUrl,但未显示任何图像.
选择的图像是.bmps.
任何帮助..请吗?
When the user clicks on a preview button i want to display the selected image in an image control.
i am getting teh path of the uploaded file in File1.Value and assigning it as teh ImageUrl but no image is being displayed.
Teh images in have selected are .bmps.
Any help.. please?
protected void btnPreview_Click(object sender, EventArgs e)
{
if (File1.PostedFile != null)
{
Image6.ImageUrl = File1.Value;
}
}
}
}
推荐答案
string path = Server.MapPath("") + @"\UserImages\image" + CurrentImage + ".jpg";
//This will create one path for CurrentImage.jpg
FileStream fs = File.Create(path);
fs.Write(ImageUpload.FileBytes, 0, ImageUpload.FileBytes.Length);
fs.Close();
//saving the uploaded file in that path
Image6.ImageUrl=path;// or \UserImages\image" + CurrentImage + ".jpg";
这篇关于抢先形象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!