jquery文件上传 - 如何覆盖文件不重命名 [英] jquery file upload - how to overwrite file NOT rename

查看:177
本文介绍了jquery文件上传 - 如何覆盖文件不重命名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很努力地更新Jquery文件上传插件,所以当你上传一个文件时,它只是用相同的名字覆盖一个现有的文件,而不是重新命名它。



我已经应用了此链接所涵盖的更改: https:// github。 com / blueimp / jQuery-File-Upload / issues / 1965

但是我似乎无法覆盖这个插件来实现这个功能?



这里还有一个尚未解答的问题:通过bluimp上传jQuery文件上传,如何替换而不是重命名



有关这方面的任何指导将非常感激。

解决方案

如果使用wiki中存在的UploadHandler.php,那很简单。在get_file_name方法中,您应该替换这一行:

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

用这个:

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


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.

解决方案

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);

这篇关于jquery文件上传 - 如何覆盖文件不重命名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆