javascript - 如果做到614时 用新上传的资源 代替原来的资源?

WBOY
Release: 2016-06-06 20:11:10
Original
847 people have browsed it

在项目中有一些需求 比如用户的头像,我将其命名为 用户id.jpg 这样方便查找。 前端用js 直传时 有时用户只是更新图像 ,这样在再次以此用户id.jpg 上传图像资源时 就会直接失败 。我想要的效果是 直接把原来的图像更新掉 原来的删掉 用上新增的。 请问要如何做到? 我能想到的方案是 先检查有没有旧的,有的话 先http 让业务服务器删掉,成功删掉返回后 再上传。 这样做很麻烦 而且我也没试成功。 是否有简单的方法呢?

回复内容:

在项目中有一些需求 比如用户的头像,我将其命名为 用户id.jpg 这样方便查找。 前端用js 直传时 有时用户只是更新图像 ,这样在再次以此用户id.jpg 上传图像资源时 就会直接失败 。我想要的效果是 直接把原来的图像更新掉 原来的删掉 用上新增的。 请问要如何做到? 我能想到的方案是 先检查有没有旧的,有的话 先http 让业务服务器删掉,成功删掉返回后 再上传。 这样做很麻烦 而且我也没试成功。 是否有简单的方法呢?

如果你附件以文件形式存储在硬盘,上传后,在后台直接覆盖保存

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!