Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes, you can encode the filename using the encodeURIComponent() function before sending it to the server. This will replace the spaces with their respective encodings ("%20"), allowing the filename to be downloaded with multiple spaces intact. Here is an example code snippet:

const fileName = "file name with multiple spaces.txt";
const url = `https://example.com/download?fileName=${encodeURIComponent(fileName)}`;

// use the url to initiate the file download

On the server-side, you can retrieve the original filename by decoding the encoded filename using the decodeURIComponent() function.