html의 input type=file인 경우 파일 첨부 버튼을 일반적으로 다른것으로 대치를 하지 못하는데
그것을 가능하도록 작성한 소스~
G메일에서 파일 첨부하는 방식과 비슷 ㅎㅎ
아래 참고, 첨부 다운로드;;
-[소스]------------------------------------------------------------------------------
<HTML>
<HEAD>
</HEAD>
<script>
/**
* 첨부 파일 입력.
*/
function cfSetFile(param) {
var f = form1;
var fileName = f.oFileAttached.value;
if (f.coOldFileName.value == "")
{
f.coOldFileName.value = f.coAttchedFileName.value;
}
f.coFileName.value = fileName.substring(fileName.lastIndexOf("\\")+1);
}
* 첨부 파일 입력.
*/
function cfSetFile(param) {
var f = form1;
var fileName = f.oFileAttached.value;
if (f.coOldFileName.value == "")
{
f.coOldFileName.value = f.coAttchedFileName.value;
}
f.coFileName.value = fileName.substring(fileName.lastIndexOf("\\")+1);
}
/**
* 첨부한 파일 삭제. (화면에서만...)
*/
function cfDelFile() {
var f = form1;
if (f.coOldFileName.value == "")
{
f.coOldFileName.value = f.coAttchedFileName.value;
}
f.coAttchedFileName.value = "";
f.coFileName.value = "";
f.oFileAttached.outerHTML = "<input type=file name=oFileAttached id=oFileAttached onchange=cfSetFile(this) size=1 style=width:0;cursor:pointer>";
}
</script>
* 첨부한 파일 삭제. (화면에서만...)
*/
function cfDelFile() {
var f = form1;
if (f.coOldFileName.value == "")
{
f.coOldFileName.value = f.coAttchedFileName.value;
}
f.coAttchedFileName.value = "";
f.coFileName.value = "";
f.oFileAttached.outerHTML = "<input type=file name=oFileAttached id=oFileAttached onchange=cfSetFile(this) size=1 style=width:0;cursor:pointer>";
}
</script>
<body>
<form name=form1>
<!-- OLD_FILE_NAME -->
<input type=hidden name=coOldFileName id=coOldFileName>
<!-- OLD_FILE_NAME -->
<input type=hidden name=coOldFileName id=coOldFileName>
<!-- ORIGINAL FILE -->
<input type=hidden name=coAttchedFileName id=coAttchedFileName>
<input type=hidden name=coAttchedFileName id=coAttchedFileName>
<input type=text name=coFileName id=coFileName style="color: #434343;border-width:1;border-color:#999999;border-style:solid;BACKGROUND-COLOR: #ffffff;FONT-SIZE: 12px;" style="WIDTH: 175px;height:19" readonly>
<fieldset style=padding:0px;background-color:#eeeeee;font-size:9pt;width:53;height:19;align:center;position:relative;top:0>
<div id=display_items height=10>파일첨부</div>
</fieldset>
<fieldset style=padding:0px;background-color:#eeeeee;font-size:9pt;width:53;height:19;align:center;position:relative;top:0;cursor:hand>
<div id=display_items height=10 onclick="cfDelFile()">첨부취소</div>
</fieldset>
<div style='width:54;height:10;left:175;overflow:hidden;position:relative;top:-18px;filter:alpha(opacity=0);-moz-opacity:0'>
<span id=file_item1><input type=file name="oFileAttached" id="oFileAttached" onchange=cfSetFile(this) size=1 style=width:0;cursor:pointer></span>
</div>
</form>
<fieldset style=padding:0px;background-color:#eeeeee;font-size:9pt;width:53;height:19;align:center;position:relative;top:0>
<div id=display_items height=10>파일첨부</div>
</fieldset>
<fieldset style=padding:0px;background-color:#eeeeee;font-size:9pt;width:53;height:19;align:center;position:relative;top:0;cursor:hand>
<div id=display_items height=10 onclick="cfDelFile()">첨부취소</div>
</fieldset>
<div style='width:54;height:10;left:175;overflow:hidden;position:relative;top:-18px;filter:alpha(opacity=0);-moz-opacity:0'>
<span id=file_item1><input type=file name="oFileAttached" id="oFileAttached" onchange=cfSetFile(this) size=1 style=width:0;cursor:pointer></span>
</div>
</form>
No comments:
Post a Comment