在asp.net 4.0中上传后加载图像
我的问题是图像上传,上传和图像加载方法工作正常,但我在上传控件下方显示图像,单击上传按钮后必须将新图像添加到行中..原因是什么?
这是上传代码:
DirectoryInfo directoryInfo = new DirectoryInfo(Server.MapPath(@"~/Bailiffs/BailiffImages/"));
string cukurNumber = txtCukurNumber.Text;
int sequence = 0;
string fileName = string.Empty;
FileInfo[] fileInfos = directoryInfo.GetFiles(cukurNumber + "*");
if (afuImage.HasFile)
{
if (fileInfos.Length != 0)
{
for (int i = 0; i < fileInfos.Length; i++)
{
string fileNumber = fileInfos[i].Name.Substring(fileInfos[i].Name.LastIndexOf("-") + 1, fileInfos[i].Name.LastIndexOf(".") - fileInfos[i].Name.LastIndexOf("-") - 1);
sequence = int.Parse(fileNumber) + 1;
}
fileName = cukurNumber + "--" + sequence + ".jpg";
}
else
{
fileName = cukurNumber + "--1.jpg";
}
afuImage.PostedFile.SaveAs(Server.MapPath(@"/Bailiffs/BailiffImages/" + fileName));
CreateImages(); // recreates images
}
thx...
My question is image uploading , uploading and image load method are working perfect but im showing images below the upload control, after click upload button new image must be added to line.. what is the reason?
this is uploading code:
DirectoryInfo directoryInfo = new DirectoryInfo(Server.MapPath(@"~/Bailiffs/BailiffImages/"));
string cukurNumber = txtCukurNumber.Text;
int sequence = 0;
string fileName = string.Empty;
FileInfo[] fileInfos = directoryInfo.GetFiles(cukurNumber + "*");
if (afuImage.HasFile)
{
if (fileInfos.Length != 0)
{
for (int i = 0; i < fileInfos.Length; i++)
{
string fileNumber = fileInfos[i].Name.Substring(fileInfos[i].Name.LastIndexOf("-") + 1, fileInfos[i].Name.LastIndexOf(".") - fileInfos[i].Name.LastIndexOf("-") - 1);
sequence = int.Parse(fileNumber) + 1;
}
fileName = cukurNumber + "--" + sequence + ".jpg";
}
else
{
fileName = cukurNumber + "--1.jpg";
}
afuImage.PostedFile.SaveAs(Server.MapPath(@"/Bailiffs/BailiffImages/" + fileName));
CreateImages(); // recreates images
}
thx...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 ajax 调用页面方法,该方法检索刚刚上传的图像的 url 并将其显示在 img 标签中。 Ajax 和 Jquery 是您的工具和朋友。
Use ajax to call a page method which retrieves the url of the image just uploaded and shows it in an img tag. Ajax and Jquery are your tools and friends.