利用ashx檔案實現檔案的上傳功能

2021-09-26 21:04:42 字數 1893 閱讀 1138

原來以為檔案上傳是乙個比較簡單的功能,結果搞了乙個晚上才搞定~這裡主要介紹兩種方法實現。

方法一:form表單提交

html**:

>

>

charset

="utf-8"

/>

>

上傳檔案title

>

src=

"scripts/jquery-1.11.3.min.js"

>

script

>

head

>

>

action

="uploadhandler.ashx"

method

="post"

enctype

="multipart/form-data"

>

"file_upload"

name

="file_upload"

type

="file"

/>

"btn_upload"

type

="submit"

value

="上傳"

/>

form

>

body

>

html

>

uploadhandler.ashx**:

using system;

using system.collections.generic;

using system.linq;

using system.web;

public

bool isreusable

}}}

該方法雖然能夠實現檔案的上傳,但是form表單提交之後整個頁面就重新整理了,如果要無重新整理上傳檔案的話,就要使用ajax了。

方法二:jquery + ajax無刷上傳

html**:

>

>

charset

="utf-8"

/>

>

上傳檔案title

>

src=

"scripts/jquery-1.11.3.min.js"

>

script

>

head

>

>

"file_upload"

name

="file_upload"

type

="file"

/>

"btn_upload"

type

="button"

value

="上傳"

/>

>

$(document)

.ready

(function()

else}}

)});

});script

>

body

>

html

>

uploadhandler.ashx**:

using system;

using system.collections.generic;

using system.linq;

using system.web;

else

}public

bool isreusable

}}}

個人更推薦方法二,執行結果如下圖所示:

檔案上傳利用

使用工具 一句話 用於執行webshall程式 中國菜刀 遠端控制 御劍 掃瞄 後台登入頁面 iiswrite put檔案上傳工具 檔案上傳漏洞是指網路攻擊者上傳了乙個可執行的檔案到伺服器並執行。這裡上傳的檔案可以是木馬,病毒,惡意指令碼或者webshell等。這種攻擊方式是最為直接和有效的,部分檔...

利用flash PHP上傳檔案

廢話少說,先看flash 在flash中新建乙個文件,放上兩個button,乙個progressbar元件 import flash.net.filereference import mx.controls.alert var my pb mx.controls.progressbar var ma...

利用fileReader上傳檔案

上傳檔案 list.resource change changeresfile el radio el radio el radio group fileitem style margin left 25px 本地上傳 type file id fileid ref fileid title cha...