Issues with uploading the same image

I have this ajax post method

 unction imageUpload(myType, myData, createType) {
        currentUsername = currentUser.username;
        var formData = new FormData();
        formData.append('username', currentUsername);
        formData.append('type', myType);
        formData.append('file', myData);

        formData.append('synchronous', 'false');
        $.ajax({
            
            url: "/uploads.json",
            type: "post",
            data: formData,
            processData: false,
            contentType: false,
            headers: {
                'X-CSRF-Token': getCsrftoken()
            }

I´m having problems uploading the same image inside a topics. After some testing I discovered that, the issue is caused by the file name. discourse don’t allow to upload files with the same file name.

Is there a way, I can change the file name of the uploaded file on upload?

Can you explain what are you trying to do?

1 Like