I'm trying to change the filename of a File
object via javascript:
<html>
<head><title>test</title></head>
<body>
<input type="file" id="file" onchange="__func(this)">
</body>
<script>
function __func(target)
{
let file = target.files[0];
file = new File(
file.slice(0, file.size),
file.name,
{type: 'text/csv'}
);
console.log(file);
}
</script>
</html>
Even if slice
returns a Blob
object, and File
constructor does accept a Blob
object as first parameter, I receive the following error:
Argument 1 of File constructor can't be converted to a sequence.
How can I solve it?