清空附件内容的方法

弄了好久,最后经高人指点得正解:
frm.elements["fileX"].select();
document.execCommand('Delete');


例子:
<html>
<head>
<script>
	function deleteFile(){
		frm.elements["fileX"].select();
		document.execCommand('Delete'); 
	}
</script>
</head>
<body>
<form id=frm action="abc.do" enctype="multipart/form-data" method="post">
      <input id='fileX' name="fileX" style="width:50% " type="file" /><input type="button" filename="file0" class="smallButton" value="×"  onclick="deleteFile()">
	<input type="submit" value="提交" />
</form>
</body>
</html>

你可能感兴趣的:(java)