# 上传同一张图片时遇到的问题

**URL:** <https://meta.discourse.org/t/issues-with-uploading-the-same-image/96073>\
**Category:** Development\
**Created:** [2018年八月31日 07:47 UTC](https://meta.discourse.org/t/issues-with-uploading-the-same-image/96073 "2018-08-31T07:47:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edwin\_Mhoy\_Silva](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/edwin_mhoy_silva/32/109980_2.png) [@Edwin\_Mhoy\_Silva](https://meta.discourse.org/u/Edwin_Mhoy_Silva)\
**Post date:** [2018年八月31日 07:47 UTC](https://meta.discourse.org/t/issues-with-uploading-the-same-image/96073/1 "2018-08-31T07:47:32Z")

</div>

I have this ajax post method

```plaintext
 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?

---

<div class="post-metadata">

**Author:** ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)\
**Post date:** [2018年九月18日 09:08 UTC](https://meta.discourse.org/t/issues-with-uploading-the-same-image/96073/2 "2018-09-18T09:08:11Z")

</div>

Can you explain what are you trying to do?
