.net自带的是FileUpLoad空间,只能选择某个文件,如果我想选择文件夹请问该如何写呢?就是弹出一个对话框,让用户选择自己本地的某个文件夹返回给textbox,请问该如何处理?谢谢!

解决方案 »

  1.   

    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;
    }
    }
    }
    }
    }
    }
      

  2.   

    LZ LOOKhttp://rczjp.cn/HTML/091208/20093308093359.html
      

  3.   

    用FolderNameEditor这个方法根本不可行!达不到预期的效果!
      

  4.   

    这个问题还真有点难 可以像腾讯相册那样做个activex控件
      

  5.   

    又做ActiveX啊?才做了一个又要做!做那玩意老烦躁的!又是签名又是浏览器权限,又是客户端权限!~烦躁的一腿!
      

  6.   

        我也是想 让用户选择自己本地的某个文件夹返回给textbox,根本不用上传文件
    是做参数配置使用的
     
      

  7.   

       你很烧饼,WinForm的还用你说
      

  8.   

    目前为止我看也就只能借助于AJAX、JQUERY之类的来实现了!
      

  9.   

    坐等!!!activex或者用ajax及jquery之类的如何实现啊?
      

  10.   

    <input type="file" />   你们是不是在找这个   HTML表单元素,通过表单对象的value获取路径,剩下的问题应该不大了
      

  11.   

    我用的VS2010可以FileUpload可以实现,以下是MSDN中的介绍:
    FileUpload类显示一个文本框控件和一个浏览按钮,使用户可以选择客户端上的文件并将它上载到Web服务器.用户通过在控件的文本框中输入本地计算机上文件的完整路径(例如,C:\MyFiles\TestFile.txt)来指定要上载的文件.用户也可以通过单击"浏览"按钮,然后在"选择文件"对话框中定位文件来选择文件,使用FileName属性来获取客户端上将使用FileUpload控件上载的文件名称.此属性返回的文件名不包含文件在客户端上的路径.