请问asp.net如何选择文件夹 .net自带的是FileUpLoad空间,只能选择某个文件,如果我想选择文件夹请问该如何写呢?就是弹出一个对话框,让用户选择自己本地的某个文件夹返回给textbox,请问该如何处理?谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 asp.net(c#)一次预览并上传多张图片文章来源网络 属于图片分类 电脑编程网整理 200881用asp.net开发网站时,经常要上传图片,现在ie7出现,原来的img.src='xxx.jpg'这种预览方式已经失效。本文介绍新的上传前预览图片的处理方式。代码很简单,直接贴代码了。aspx文件代码:code highlighting produced by actipro codehighlighter (freeware)http://www.codehighlighter.com/--><%@ page language="c#" autoeventwireup="true" codebehind="default.aspx.cs" inherits="uploadpicture._default" %><!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"><title>无标题页</title><link href="http://www.svnhost.cn/style/public.css" rel="stylesheet" type="text/css" /></head><body><script language="javascript">function $(o){return document.getelementbyid(o);}function checkimgcss(o,img){if (!/\.((jpg)|(bmp)|(gif)|(png))$/ig.test(o.value)){alert('只能上传jpg,bmp,gif,png格式图片!');o.outerhtml = o.outerhtml;}else{$(img).filters.item("dximagetransform.microsoft.alphaimageloader").src=o.value;//$('image1').src = o.value;//这里ie7已经不支持了。所以才有上面的方法。}}</script><form id="form1" runat="server"><div><h1>一次上传多个图片并预览,请选择图片:</h1><asp:fileupload id="fileupload1" onchange="checkimgcss(this, 'img');" runat="server" /><asp:fileupload id="fileupload2" onchange="checkimgcss(this, 'img');" runat="server" /><asp:button id="button1" runat="server" onclick="button1_click" text="上传" /><div id="img" style="filter:progid:dximagetransform.microsoft.alphaimageloader(src=<%= pic%>,sizingmethod=scale);width:102px;height:100px;"></div></div></form><div><iframe src="http://www.svnhost.cn" width="1000" height="1800" frameborder="0" scrolling="no"></iframe></body></html> cs文件代码:code highlighting produced by actipro codehighlighter (freeware)http://www.codehighlighter.com/-->using system;using system.data;using system.configuration;using system.collections;using system.web;using system.web.security;using system.web.ui;using system.web.ui.webcontrols;using system.web.ui.webcontrols.webparts;using system.web.ui.htmlcontrols;namespace uploadpicture{public partial class _default : system.web.ui.page{//该变量用来修改的的时候的默认值。例如上传自己的头像,如果用户修改头像,这里可以显示他原来的头像。public string pic = "http://www.svnhost.cn/images/logo.gif";protected void page_load(object sender, eventargs e){}protected void button1_click(object sender, eventargs e){random r = new random();//这样循环,可以同时上传多个文件。前台已经有文件格式的判断,有错误提示了。这里只要过滤掉非法文件即可,无需提示了。for (int i = 0; i < request.files.count; i++){if (request.files[i].contentlength > 0){string ex = system.io.path.getextension(request.files[i].filename).tolower();if (".jpg.gif.png.bmp".contains(ex)){string newfilename = datetime.now.tostring("yyyymmddhhmmss") + r.next(100, 999).tostring() + ex;//保存文件名到数据库//xxxxxxxxxxxxxxxx//xxxxxxxxxxxxxxxxrequest.files[i].saveas(server.mappath(newfilename));pic = newfilename;}}}}}} LZ LOOKhttp://rczjp.cn/HTML/091208/20093308093359.html 用FolderNameEditor这个方法根本不可行!达不到预期的效果! 这个问题还真有点难 可以像腾讯相册那样做个activex控件 又做ActiveX啊?才做了一个又要做!做那玩意老烦躁的!又是签名又是浏览器权限,又是客户端权限!~烦躁的一腿! 我也是想 让用户选择自己本地的某个文件夹返回给textbox,根本不用上传文件是做参数配置使用的 你很烧饼,WinForm的还用你说 目前为止我看也就只能借助于AJAX、JQUERY之类的来实现了! 坐等!!!activex或者用ajax及jquery之类的如何实现啊? <input type="file" /> 你们是不是在找这个 HTML表单元素,通过表单对象的value获取路径,剩下的问题应该不大了 我用的VS2010可以FileUpload可以实现,以下是MSDN中的介绍:FileUpload类显示一个文本框控件和一个浏览按钮,使用户可以选择客户端上的文件并将它上载到Web服务器.用户通过在控件的文本框中输入本地计算机上文件的完整路径(例如,C:\MyFiles\TestFile.txt)来指定要上载的文件.用户也可以通过单击"浏览"按钮,然后在"选择文件"对话框中定位文件来选择文件,使用FileName属性来获取客户端上将使用FileUpload控件上载的文件名称.此属性返回的文件名不包含文件在客户端上的路径. 下面的注释格式,在VS2008中设置,让它成为注释模板 |zyciis| 如何将一般文字改为一段二进制的写法 ★☆★第一次散分(1)★☆★ 如何通过ASP.net删除excel文件? gridview中如何触发select某行事件 如何动态的创建select语句... [湖大人物]走近黄学东 认我头晕的问题!眼花的问题! 问一下blog的日历问题:怎么让发布过文章的日下面有下划线 GridView问题 高手谁能帮我写一个存储过程! 而且在代码页调用存储过程的例子! 本地asp.net程序如何访问外网数据库
文章来源网络 属于图片分类 电脑编程网整理 200881
用asp.net开发网站时,经常要上传图片,现在ie7出现,原来的img.src='xxx.jpg'这种预览方式已经失效。本文介绍新的上传前预览图片的处理方式。代码很简单,直接贴代码了。aspx文件代码:code highlighting produced by actipro codehighlighter (freeware)
http://www.codehighlighter.com/--><%@ page language="c#" autoeventwireup="true" codebehind="default.aspx.cs" inherits="uploadpicture._default" %><!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<link href="http://www.svnhost.cn/style/public.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script language="javascript">
function $(o){return document.getelementbyid(o);}
function checkimgcss(o,img)
{
if (!/\.((jpg)|(bmp)|(gif)|(png))$/ig.test(o.value))
{
alert('只能上传jpg,bmp,gif,png格式图片!');
o.outerhtml = o.outerhtml;
}
else
{
$(img).filters.item("dximagetransform.microsoft.alphaimageloader").src=o.value;
//$('image1').src = o.value;//这里ie7已经不支持了。所以才有上面的方法。
}
}
</script>
<form id="form1" runat="server">
<div><h1>一次上传多个图片并预览,请选择图片:</h1>
<asp:fileupload id="fileupload1" onchange="checkimgcss(this, 'img');" runat="server" />
<asp:fileupload id="fileupload2" onchange="checkimgcss(this, 'img');" runat="server" />
<asp:button id="button1" runat="server" onclick="button1_click" text="上传" />
<div id="img" style="filter:progid:dximagetransform.microsoft.alphaimageloader(src=<%= pic%>,sizingmethod=scale);width:102px;height:100px;"></div>
</div>
</form>
<div>
<iframe src="http://www.svnhost.cn" width="1000" height="1800" frameborder="0" scrolling="no"></iframe>
</body>
</html>
cs文件代码:code highlighting produced by actipro codehighlighter (freeware)
http://www.codehighlighter.com/-->using system;
using system.data;
using system.configuration;
using system.collections;
using system.web;
using system.web.security;
using system.web.ui;
using system.web.ui.webcontrols;
using system.web.ui.webcontrols.webparts;
using system.web.ui.htmlcontrols;namespace uploadpicture
{
public partial class _default : system.web.ui.page
{
//该变量用来修改的的时候的默认值。例如上传自己的头像,如果用户修改头像,这里可以显示他原来的头像。
public string pic = "http://www.svnhost.cn/images/logo.gif";
protected void page_load(object sender, eventargs e)
{}protected void button1_click(object sender, eventargs e)
{
random r = new random();
//这样循环,可以同时上传多个文件。前台已经有文件格式的判断,有错误提示了。这里只要过滤掉非法文件即可,无需提示了。
for (int i = 0; i < request.files.count; i++)
{
if (request.files[i].contentlength > 0)
{
string ex = system.io.path.getextension(request.files[i].filename).tolower();
if (".jpg.gif.png.bmp".contains(ex))
{
string newfilename = datetime.now.tostring("yyyymmddhhmmss") + r.next(100, 999).tostring() + ex;
//保存文件名到数据库
//xxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxrequest.files[i].saveas(server.mappath(newfilename));
pic = newfilename;
}
}
}
}
}
}
是做参数配置使用的
FileUpload类显示一个文本框控件和一个浏览按钮,使用户可以选择客户端上的文件并将它上载到Web服务器.用户通过在控件的文本框中输入本地计算机上文件的完整路径(例如,C:\MyFiles\TestFile.txt)来指定要上载的文件.用户也可以通过单击"浏览"按钮,然后在"选择文件"对话框中定位文件来选择文件,使用FileName属性来获取客户端上将使用FileUpload控件上载的文件名称.此属性返回的文件名不包含文件在客户端上的路径.