ankitpokhrel / tus-php

🚀 A pure PHP server and client for the tus resumable upload protocol v1.0.0

Home Page:https://tus.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Upload fails when file name contains an apostrophe

gavrochelegnou opened this issue · comments

commented

Hello,

If a file name contains an apostrophe ex. : "i won't upload.jpg" the upload always fails with a 400 error.

I'm using uppy to upload.

Failed to upload tes't.png tus: unexpected response while creating upload, originated from request (method: POST, url: /uploads/, response code: 400, response text: , request id: n/a)

This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.

commented

This is related to #333

Current implementation doesn't allow following characters in filenames '../', '"', "'", '&', '/', '\\', '?', '#', ':', however this is not true for all systems and this should be configurable IMO.

As a workaround you can rename the file before uploading, for example with uppy:

onBeforeFileAdded: (currentFile, files) => {
    var modifiedFile = Object.assign({}, currentFile, {
        name: currentFile.name.replace(" ", "-") // clean spaces
    });
    uppy.info(modifiedFile);
    return modifiedFile;
}