원칙 코드 :
strfilename = request.querystring ( "file1") set objstream = server.createobject ( "adodb.stream") objstream.type = 1 'adtypebinary objstream.open objstream.loadfromfile strfilename objstream.savetofile server.mappath ( "123_onweb.gif"), 2 |
사용 방법 :
위의 코드를 업로드로 작성하십시오
입력하다:
http : //xxx/upload.asp? file1 = c :/upload 파일/123.gif
XXX는 호스트 주소입니다
실행 후 디렉토리에 추가 123_onweb.gif가 있음을 알 수 있습니다.
그는 당신이 파일을 원하는 것입니다
원칙에 따라 다음 코드를 확장 할 수 있습니다.
upload.htm 파일
<form name = "form"action = "upload.asp"method = "post"> <input type = "file"name = "file1"value = ""> <입력 유형 = "제출"이름 = "제출"value = "ok"> </form> |
upload.asp 파일
<% 함수 getFileName (byval strfile) strfile <> ""라면 getFilename = mid (strfile, instrev (strfile, "/")+1) 또 다른 getFilename = "" 끝 If 엔드 기능 strfilename = request.form ( "file1") set 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 모드가 통과되지 않습니다!