Dropzone.js dropzone.zs在上载之前/上载时重命名所有文件

Dropzone.js dropzone.zs在上载之前/上载时重命名所有文件,dropzone.js,Dropzone.js,我在使用dropzone.js通过拖放上传文件时遇到了这个问题 假设我有这个表格: <form action=""<?php echo $_SERVER['PHP_SELF'];?>"" enctype=""multipart/form-data"" class=""dropzone"" id=""dropzone1""> <input type=""text"" name=""somevalue"" id=""somevalue"" value=""someval

我在使用dropzone.js通过拖放上传文件时遇到了这个问题

假设我有这个表格:

<form action=""<?php echo $_SERVER['PHP_SELF'];?>"" enctype=""multipart/form-data"" class=""dropzone"" id=""dropzone1"">
<input type=""text"" name=""somevalue"" id=""somevalue"" value=""somevalue"" />
<div class=""fallback"">
<input type=""file"" name=""file-image"" />
</div>
</form>
dropzone调用的javascript是:

<script type=""text/javascript"">
$(document).ready(function() {

Dropzone.autoDiscover = false;
            var fileList = new Array;
            var i =0;

$(""#dropzone1"").dropzone({

 init: function() {
        var $this = this;

        $(""#submit-all-1"").click(function() {
            $this.processQueue();
        });

   var totalFiles = 0,completeFiles = 0;
        this.on(""addedfile"", function (file) {
            totalFiles += 1;
   var numQueued=this.getQueuedFiles().length;
        });

  this.on(""success"", function(file, serverFileName) {
              fileList[i] = {""serverFileName"" : serverFileName, ""fileName"" : file.name,""fileId"" : i };
              i++;
  });

        this.on(""removed file"", function (file) {
            totalFiles -= 1;
        });
        this.on(""complete"", function (file) {
            completeFiles += 1;
            if (completeFiles === totalFiles) {
   // Do something
            }
        });
    },
 paramName: 'file-image',
 acceptedFiles:'image/*',
 autoProcessQueue:false,
 addRemoveLinks: true,
    parallelUploads: 10
 }); 
/////////////////////////////////
});
</script>
在php部分:

<?php
if (!empty($_FILES)) {

$somevalue=$_POST['somevalue'];
$counter=1;

  $image=$_FILES['file-image']['name']); 
  $picture_in = ""/PicsUrl/"".$somevalues.$counter.$image;
  move_uploaded_file($_FILES['file-image']['tmp_name'], $picture_in);

$counter++;
}
?>
我想这样做:

发布了$somevalue,我同时上传的所有文件, 改名如下:

$somevalue\u 1\u imagefilename、$somevalue\u 2\u imagefilename、$somevalue\u 3\u imagefilename

等等


有什么帮助吗?

请尝试更改PHP脚本,如下所示:

<?php
if (!empty($_FILES)) {

$somevalue=$_POST['somevalue'];
$counter=1;

  $image=$_FILES['file-image']['name']); 
  $picture_in = ""/PicsUrl/"".$somevalue.$counter++.$image;
  move_uploaded_file($_FILES['file-image']['tmp_name'], $picture_in);
}
?>