dtqie02844 2018-04-19 07:39 采纳率: 0%
浏览 32
已采纳

在DropzoneJS中将数据传递给php [重复]

This question already has an answer here:

I am a fresher to use DropzoneJS. this is my form

<div class="col-md-12">
    <form action="upload.php" enctype="multipart/form-data" class="dropzone" id="myDropzone" method="post"></form>
    <select id="category" style="display: none;">
        <option value="">Select Category</option>
        <option value="cat1">Category 1</option>
        <option value="cat2">Category 2</option>
        <option value="cat3">Category 3</option>
    </select>
    <span id="caterr" style="color: red"></span>
    <button id="submit-all" style="display: none;">Submit all files</button>
</div>

And here is my dropzone code

Dropzone.options.myDropzone = {
// Prevents Dropzone from uploading dropped files immediately
autoProcessQueue: false,
acceptedFiles: ".png,.jpg,.jpeg",
maxFilesize: 2,
parallelUploads: 20,
addRemoveLinks: true,
    init: function() {
        myDropzone = this;
        $("#submit-all").click(function(){
            myDropzone.processQueue();
        })
    }
};

And Here is php

if (!empty($_FILES)) 
{
    $filename = $_FILES['file']['name'];
    $tmpFile = $_FILES['file']['tmp_name'];
    move_uploaded_file($tmpFile,$filename);
}

Now the reuirement is i wants to send an <selected> Category to PHP Page. So i can insert php category in database. but how can i send this selected category to php page.

</div>
  • 写回答

1条回答 默认 最新

  • dqkkrt8860 2018-04-19 08:24
    关注

    update your init by this codes

    init: function() {
        myDropzone = this;
        $("#submit-all").click(function(){
            myDropzone.processQueue();
        });
        myDropzone.on('sending', function(file, xhr, formData){     
            formData.append('category',$('#category').val());
        });
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失