function ReportFileStatus(filespec)
{
var fso, s = filespec;
fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FileExists(filespec))
s += " exists.";
else
s += " doesn't exist.";
return(s);
}
{
var fso, s = filespec;
fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FileExists(filespec))
s += " exists.";
else
s += " doesn't exist.";
return(s);
}
{
var fso, s = document.all.TextBox1.value;
alert(s);
fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FileExists(s))
{
alert("OK");
}
else
{
alert("NO");
}
}
<script>
function ReportFileStatus()
{
var fso, s = document.all.TextBox1.value;
alert(s);
fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FileExists(s))
{
alert("OK");
}
else
{
alert("NO");
}
}
</script>
<body>
<input type=text name="TextBox1" value='F:\CODE\Fudan\bin\Fudan.dll' style="width:200px">
<input type=button value='check' onclick='ReportFileStatus()'>
</body>
return (new ActiveXObject("Scripting.FileSystemObject")).FileExists(fname)
}
<!--function Button1_onclick() {
try
{
var sFile=document.all("File1").value;
var _http=new ActiveXObject("MSXML2.XMLHTTP");
_http.open("Get",sFile,false);
_http.send();
//alert(_http.statusText);
if(_http.status==404){alert('文件不存在!')}
}catch(e){
alert("OK");
}
}//-->
</script>
<INPUT id="File1" type="file" name="File1"><INPUT id="Button1" type="button" value="Button" name="Button1" onclick="return Button1_onclick()">
这个用xmlhttp应该不行吧..
也可以在这里用
不过 FireFox 没通过
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Author" CONTENT="宝玉">
<META NAME="patch" contenet="chaobill">
</HEAD>
<script language="javascript">
<!--
//检查插入是否为图片
/*
HTMLArea._addEvent = function(el, evname, func) {
if (HTMLArea.is_ie) {
el.attachEvent("on" + evname, func);
} else {
el.addEventListener(evname, func, true);
}*/
var img=null;
function chkimg(inp)
{
//alert("chkimg");
inp=document.getElementById("file1").value;
alert(inp)
if(img)img.removeNode(true);
img=document.createElement("img");
img.src="file:///"+inp;
img.style.width=100;
img.style.height=100;
img.style.visibility="hidden"
img.style.visibility="visible"
var body=document.getElementsByTagName("body")[0];
body.appendChild(img)
alert(img.src); /*var is_ie=true;
if(is_ie){
img.attachEvent("onreadystatechange",isimg);
img.attachEvent("onerror",notimg);
img.src=inp;
}else{
}*/
}
function notimg()
{
alert("您插入的不是图片,请重新选择插入");
}
function isimg()
{
var show = document.getElementById("show")
var show1 = document.getElementById("show1");
show.insertAdjacentElement("BeforeEnd",img);
show1.innerHTML = "图片大小" + img.fileSize/1024 +"K图片宽度"+ img.offsetWidth +"图片高度"+ img.offsetHeight;
}
function chkimg1()
{
alert("SDFS");
}
// -->
</script>
<BODY>
<div id="show"></div>
<div id="show1"></div>
<input type="file" id="file1" name="" onpropertychange="chkimg(this.value)"/>
<button onclick='chkimg()' >df</button>
</BODY>
</HTML>
<!--
function CheckFile(s){
var p=document.createElement('IFRAME');
var h='file:///'+s.replace(/\\/g,'/').replace(/\:/g,'|');
p.src=h;
var s=(p.readyState=='complete');
p=null;
return s;
}
alert(CheckFile('c:\\boot.ini'));
-->
</script>
<form name="form1" enctype="multipart/form-data" method="post" action="">
<input type="file" name="file" onChange="checkme(this)">
</form>
<div id="checkmeimg" style="display:none;"></div>
<script language="javascript">
function checkme(obj){
checkmeimg.innerHTML='<img src="'+obj.value+'" onerror=\'alert("not found")\' onload=\'alert("found")\'>';
}
</script>
<INPUT id="File1" type="file" name="File1" onkeydown="if (event.keyCode==8) window.onerror=new Function('return false');event.returnValue=false" onpaste="return false;">