javascript檔案上傳:多個檔案上傳的javascript編碼
來源:互聯網
上載者:User
多個檔案上傳的javascript編碼
一.技巧:
每次動態增加一個檔案上傳輸入框,都把它和刪除按紐放置在一個單獨的div中,並對刪除按紐的onclick事件進行響應,使之刪除刪除按紐所在的div。
<%@ page language="java"import="java.util.*" pageEncoding="utf-8"%>
<%
String path =request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTDHTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>上傳頁面</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet"type="text/css"
href="styles.css">
-->
<script type="text/javascript">
function addfile(){
//擷取到指定id的元素對象
var files = document.getElementById("files");
//建立一個元素對象
var input = document.createElement("input");
//元素的屬性
input.name="file"; 本文連結http://www.cxybl.com/html/wyzz/JavaScript_Ajax/20121117/33930.html