茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    asp.net獲取html表單file中的路徑的方法
    來源:易賢網(wǎng) 閱讀:1076 次 日期:2014-10-27 09:33:54
    溫馨提示:易賢網(wǎng)小編為您整理了“asp.net獲取html表單file中的路徑的方法”,方便廣大網(wǎng)友查閱!

    這篇文章主要介紹了asp.net怎么獲取html表單file中的路徑,需要的朋友可以參考下

    代碼如下:

    #region 上傳文件到數(shù)據(jù)庫和服務器

    public void fn_upfiles()

    {

    //遍歷file表單元素

    httpfilecollection files = httpcontext.current.request.files;

    try

    {

    for (int ifile = 0; ifile < files.count; ifile++)

    {

    //檢查文件擴展名字

    httppostedfile postedfile = files[ifile];

    string filename = ;//定義文件名

    //string fileextension = ;

    filename = path.getfilename(postedfile.filename);//得到上傳文件的完整名稱 即文件名+后綴名

    int index = filename.indexof(.);

    string filetype = filename.substring(index).tolower();//截取文件后綴名

    //filetypeimg = ../filetypeimg/ + hz + .gif;

    guid fileguid = guid.newguid();//生成新的文件名稱 以guid命名防止文件名相同

    string newfilename = fileguid.tostring();//新的文件名

    newfilename = newfilename + filetype;//新的文件名+后綴名

    if (postedfile.contentlength > 2097151 * 1024)//判斷是否大于配置文件中的上傳文件大小

    {

    page.registerstartupscript(提示, <script language='javascript'>alert('對不起您的上傳資源過大!');return;</script>);

    return;

    }

    else

    {

    if (filename != )//如果文件名不為空

    {

    try

    {

    //文件虛擬路徑

    string strpath = system.web.httpcontext.current.server.mappath(~/upload/) + newfilename;

    try

    {

    nrmodel.file model = new nrmodel.file();

    nrbll.file bf = new nrbll.file();

    guid guid1 = guid.newguid();

    guid guid2 = new guid(folderid);

    guid guid3 = guid.newguid();

    guid guid4 = guid.newguid();

    model.fileid = guid1;

    model.folderid = guid2;

    model.filepath = strpath;

    model.filenam = filename;

    model.filesize = postedfile.contentlength;

    model.decription = textarea1.value.tostring();

    model.createon = datetime.now;

    model.createby = guid3;

    model.modefyby = guid4;

    if (bf.fn_addnewres(model) > 0)

    {

    nr.error.log.logtype(上傳資源 + filename + 成功! + 服務器路徑: + strpath);

    //保存文件到指定目錄(虛擬目錄)

    postedfile.saveas(system.web.httpcontext.current.server.mappath(~/upload/) + newfilename);

    //page.registerstartupscript(提示, <script language='javascript'>alert('上傳成功!');self.opener.location.reload();window.close();</script>);

    alertmsg(上傳成功!);

    }

    }

    catch (exception ex)

    {

    nr.error.log.logtype(ex.tostring());

    }

    }

    catch (exception ex)

    {

    nr.error.log.logtype(ex.tostring());

    }

    }

    else

    {

    response.write(上傳文件不能為空!);

    nr.error.log.logtype(文件不能為空!);

    }

    }

    }

    }

    catch (system.exception ex)

    {

    nr.error.log.logtype(ex.tostring());

    }

    }

    #endregion

    更多信息請查看IT技術專欄

    更多信息請查看網(wǎng)頁制作
    易賢網(wǎng)手機網(wǎng)站地址:asp.net獲取html表單file中的路徑的方法
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇剩?/div>

    2026上岸·考公考編培訓報班

    • 報班類型
    • 姓名
    • 手機號
    • 驗證碼
    關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)