这是一个简单的HTML页面,可以用来编码解码文件。

<!DOCTYPE html>
<html>
<head>
	<title>文件编码解码工具</title>
</head>
<body>
	<h1>文件编码解码工具</h1>
	<form>
		<label for='file'>选择要编码或解码的文件:</label>
		<input type='file' id='file' name='file' />
		<br><br>
		<label for='type'>编码或解码:</label>
		<select id='type' name='type'>
			<option value='encode'>编码</option>
			<option value='decode'>解码</option>
		</select>
		<br><br>
		<button type='button' onclick='processFile()'>处理文件</button>
	</form>

	<script>
		function processFile() {
			var fileInput = document.getElementById('file');
			var file = fileInput.files[0];
			var typeInput = document.getElementById('type');
			var type = typeInput.value;

			if (file) {
				var reader = new FileReader();

				reader.onload = function(e) {
					var content = e.target.result;

					if (type == 'encode') {
						content = btoa(content);
					} else if (type == 'decode') {
						content = atob(content);
					}

					var link = document.createElement('a');
					link.href = 'data:text/plain;base64,' + content;
					link.download = file.name;
					link.click();
				};

				reader.readAsBinaryString(file);
			}
		}
	</script>
</body>
</html>

这个页面包含一个文件选择器和一个下拉菜单,用于选择编码或解码。当用户选择一个文件并点击“处理文件”按钮时,JavaScript代码将读取文件内容,并根据用户选择的编码或解码类型进行相应的操作。最后,它将生成一个下载链接,用户可以点击该链接以下载已处理的文件。

在线文件编码解码工具 - 免费使用

原文地址: http://www.cveoy.top/t/topic/lOGv 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录