dropzone.zs重命名上传前/上传时的所有文件

时间:2015-02-09 17:11:06

标签: 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=""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_1_imagefilename,$ somevalue_2_imagefilename,$ somevalue_3_imagefilename

等...

任何帮助?

0 个答案:

没有答案