原則コード:
strfilename = request.querystring( "file1") objstream = server.createObject( "adodb.stream")を設定します objstream.type = 1 'adtypebinary objstream.open objstream.loadfromfile strfilename objstream.savetofile server.mappath( "123_onweb.gif")、2 |
使い方:
上記のコードをupload.aspとして記述します
入力:
http://xxx/upload.asp?file1 = c:/upload file/123.gif
XXXはホストアドレスです
実行後、ディレクトリに追加の123_onweb.gifがあることがわかります
彼はあなたがファイルを望んでいるものです
原則に従って、次のコードを拡張できます。
upload.htmファイル
<form name = "form" action = "upload.asp" method = "post"> <入力型= "file" name = "file1" value = ""> <入力型= "submit" name = "submit" value = "ok"> </form> |
upload.aspファイル
<% 関数getFileName(byval strfile) strfile <> "" thenの場合 getFileName = Mid(Strfile、Instrrev(strfile、 "/")+1) それ以外 getFileName = "" ifを終了します エンド関数 strfilename = request.form( "file1") objstream = server.createObject( "adodb.stream")を設定します objstream.type = 1 'adtypebinary objstream.open objstream.loadfromfile strfilename objstream.savetofile server.mappath(getFileName(strfileName))、2 objstream.close %> |
ローカルデバッグは成功しましたが、C/Sモードは合格しません!