我需要一些幫助,將使用JavaScript代碼將上傳的csv文件內容轉換爲數組。JavaScript:將上傳的CSV文件內容轉換爲陣列
以下是我迄今所做的:
我有一個CSV文件,它包含了所有的ClientID的列表例如
ClientIDs
1
2
3
使用下面的HTML代碼,我上傳的文件
<form id = "FileUpload" method="post" enctype="multipart/form-data">
<div> <p><p>
<b>Select file containing all clientIDs:</b>
<input type="file" id="FileUpload" name="csv"/>
<input type="hidden" name="action" value="upload"/>
<input type="submit" name="FileUpload" value="Upload File"/>
</div>
</form>
現在,我卡在一部分。讀取和轉換文件內容的JS
if(document.getElementById("FileUpload").value != "") {
console.log("The file was uploaded");
//Process the file and convert its contents to array
}
有人可以幫忙嗎?
在此先感謝。
你可能想看看這裏的一些代碼示例:HTTPS ://developer.mozilla.org/en-US/docs/Using_files_from_web_applications – fet