परिचय
HTML DOM इनपुट फाइल अपलोड type प्रॉपर्टी HTML दस्तावेज़ में एक <input> एलिमेंट के type एट्रिब्यूट का मान लौटाती है। फाइल अपलोड इनपुट के लिए, यह हमेशा "file" लौटाता है।
सिंटैक्स
object.type
उदाहरण
यह उदाहरण फाइल अपलोड बटन के type प्रॉपर्टी का मान प्रदर्शित करता है:
<!DOCTYPE html>
<html>
<head>
<style>
body { text-align: center; background-color: #52B2CF; color: #fff; }
.btn {
background-color: coral;
border: none;
height: 2rem;
border-radius: 50px;
width: 60%;
margin: 1rem auto;
display: block;
color: #fff;
outline: none;
}
.show { font-size: 2rem; color: #fff; font-weight: bold; }
</style>
</head>
<body>
<h1>DOM फाइल अपलोड type प्रॉपर्टी उदाहरण</h1>
<input type="file" class="file-upload-btn">
<button onclick="getType()" class="btn">type प्रॉपर्टी का मान प्राप्त करें</button>
<div class="show"></div>
<script>
function getType() {
var fileBtn = document.querySelector(".file-upload-btn");
document.querySelector('.show').innerHTML = fileBtn.type;
}
</script>
</body>
</html>
आउटपुट
बटन पर क्लिक करने पर, फाइल अपलोड इनपुट का type "file" प्रदर्शित होगा।