像这样的代码(上传图片时执行):
gallery = Gallery.objects.get(id=album_id)
index = gallery.photo_num +1 #index will be used in later
gallery.photo_num = index
gallery.save()
1张图片上传效果很好,但如果同时上传多张图片,使用多张上传jQuery plugin.the "gallery.photo_num“会比较混乱
如何修改代码以避免此问题
因此,我为我的客户端制作了这个属性列表主题,在我创建的Properties Custom Post Type (CPT)上,我需要添加一个元框,允许他上传多张图片--类似于以下内容:
📷
我怎么能这么做?到目前为止,我所看到的一切都推荐像高级自定义字段这样的插件,但是如果可以的话,我想避免使用第三方插件。
谢谢:)
单张图片上传有效,多张图片上传无效
const data = new FormData();
//sending data to backend in the form of array
data.append("media_files", [{
uri: item.uri,
type: item.mime,
name: item.name || `filename${i}.jpg`,