在images文件夹中上传图像文件后,我需要访问img scr属性中的图像文件 [英] After uploading the image file in images folder,i need to acess that image file in img scr attribute
本文介绍了在images文件夹中上传图像文件后,我需要访问img scr属性中的图像文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
namespace ImageEx
{
public partial class UploadCrop : System.Web.UI.Page
{
String path = HttpContext.Current.Request.PhysicalApplicationPath + "images\\";
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnUpload_Click(object sender, EventArgs e)
{
Boolean FileOK = false;
Boolean FileSaved = false;
{
Session["WorkingImage"] = Upload.FileName;
String FileExtension = Path.GetExtension(Session["WorkingImage"].ToString()).ToLower();
String[] allowedExtensions = { ".png", ".jpeg", ".jpg", ".gif" };
for (int i = 0; i < allowedExtensions.Length; i++)
{
if (FileExtension == allowedExtensions[i])
{
FileOK = true;
}
}
}
if (FileOK)
{
try
{
Upload.PostedFile.SaveAs(path + Session["WorkingImage"]);
FileSaved = true;
}
catch (Exception ex)
{
LblError.Text = "File could not be uploaded." + ex.Message.ToString();
LblError.Visible = true;
FileSaved = false;
}
}
else
{
LblError.Text = "Cannot accept files of this type.";
LblError.Visible = true;
}
if (FileSaved)
{
pnlUpload.Visible = false;
pnlCrop.Visible = true;
imgCrop.ImageUrl = "images/" + Session["WorkingImage"].ToString();
}
}
}
}
以上是我的代码隐藏文件
$('
The above is my codebehind file
$('
< img src =
<img src=" "
'))
.css
{//一些代码
}
'))
.css
{//some code
}
推荐答案
('
< img src =
<img src=" "
'))
.css
{ //一些代码
}
'))
.css
{//some code
}
对于图像src,指定完整的URL到图像文件。例如:http://www.test.com/images/testimage.jpg。这将显示图像
For the image src specify the full url to the image file.For eg: http://www.test.com/images/testimage.jpg. This will display the image
这篇关于在images文件夹中上传图像文件后,我需要访问img scr属性中的图像文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文