Upload file
Đôi khi trong một số trường hợp ta dùng liên kết để upload file thay vì dùng mặc định từ input type=”file”
<input type="file"> được thay thế bằng liên kết
Sử dụng một liên kết để thay thế cho <input type="file">
Html viết:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Học Web Chuẩn</title>
<script src="https://code.jquery.com/jquery-latest.js"></script>
<script>
$(function(){
var upFile = $(":input[type=file]");
upFile.hide();
$("a.file").click(function(){
upFile.click();
});
});
</script>
</head>
<body>
<form>
<a class="file" href='javascript:;'>Upload file</a>
<input type="file"/>
</form>
</body>
</html>

