jquery file upload - how to overwrite file NOT rename

user1746582 picture user1746582 · Feb 9, 2013 · Viewed 8.8k times · Source

I am struggling to update the Jquery file upload plugin so when you upload a file it just overwrites an existing file with the same name instead of renaming it with an upcount.

I have applied the change covered in this link: https://github.com/blueimp/jQuery-File-Upload/issues/1965

but I can't seem overwrite this plugin to get this working?

there's an existing open question not yet answered here: jQuery File Upload by bluimp, how to replace instead of renaming

any guidance on this would be much appreciated.

Answer

MKoosej picture MKoosej · Jul 11, 2013

If you using UploadHandler.php that is exists in the wiki it's simple. In the get_file_name method you should replace this line:

    return $this -> get_unique_filename($this -> trim_file_name($name, $type, $index, $content_range), $type, $index, $content_range);

with this:

 return $this -> trim_file_name($name, $type, $index, $content_range);