Drag and Drop Multiple File Upload – Contact Form 7 - Version 1.2.6

Version Description

= 1.2.3 = This version fixed minor issues/bugs and add multiple drag and drop fields in a form.

= 1.2.1 = This version fixed minor issues and bugs.

= 1.2.2 = Added some usefull features.

= 1.2.4 = Added new features and fixes.

Download this release

Release Info

Developer glenwpcoder
Plugin Icon 128x128 Drag and Drop Multiple File Upload – Contact Form 7
Version 1.2.6
Comparing to
See all releases

Code changes from version 1.2.5 to 1.2.6

assets/css/dnd-upload-cf7.css CHANGED
@@ -131,4 +131,11 @@
131
  /* Add border on dragenter, drag etc */
132
  .codedropz-dragover {
133
  border-color:#6b6a6a;
 
 
 
 
 
 
 
134
  }
131
  /* Add border on dragenter, drag etc */
132
  .codedropz-dragover {
133
  border-color:#6b6a6a;
134
+ }
135
+
136
+ .codedropz-upload-wrapper span.has-error-msg {
137
+ display:inline-block;
138
+ color:#fd3939;
139
+ padding:5px 0;
140
+ font-style:italic;
141
  }
assets/js/codedropz-uploader-min.js CHANGED
@@ -1,21 +1,11 @@
1
  /**
2
- * CodeDropz Uploader v1.0
3
  * Copyright 2018 Glen Mongaya
4
  * CodeDrop Drag&Drop Uploader
5
- * @version 1.0
6
  * @author CodeDropz, Glen Don L. Mongaya
7
  * @license The MIT License (MIT)
8
  */
9
 
10
  // CodeDropz Drag and Drop Plugin
11
- (function($){$.fn.CodeDropz_Uploader=function(settings){var options=$.extend({handler:this,color:"#000",background:'',server_max_error:'Uploaded file exceeds the maximum upload size of your server.',max_file:10,text:'Drag & Drop Files Here',separator:'or',button_text:'Browse Files',max_upload_size:'5242880',supported_type:'jpg|jpeg|JPG|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv',on_success:''},settings);var count_files=1;var cdropz_template='<div class="codedropz-upload-handler">'+'<div class="codedropz-upload-container">'+'<div class="codedropz-upload-inner">'+'<h3>'+options.text+'</h3>'+'<span>'+options.separator+'</span>'+'<div class="codedropz-btn-wrap"><a class="cd-upload-btn" href="javascript:void(0)">'+options.button_text+'</a></div>'+'</div>'+'</div>'+'</div>';options.handler.wrapAll('<div class="codedropz-upload-wrapper"></div>');var form_handler=options.handler.parents('form'),options_handler=options.handler.parents('.codedropz-upload-wrapper'),btnOBJ=$('input[type="submit"]',form_handler);options.handler.after(cdropz_template);$('.codedropz-upload-handler',options_handler).on('drag dragstart dragend dragover dragenter dragleave drop',function(e){e.preventDefault();e.stopPropagation()})
12
- $('.codedropz-upload-handler',options_handler).on('dragover dragenter',function(e){$(this).addClass('codedropz-dragover')});$('.codedropz-upload-handler',options_handler).on('dragleave dragend drop',function(e){$(this).removeClass('codedropz-dragover')});$('a.cd-upload-btn',options_handler).on("click",function(e){e.preventDefault();options.handler.click()});$('.codedropz-upload-handler',options_handler).on('drop',function(event){DND_Setup_Uploader(event.originalEvent.dataTransfer.files,'drop')});options.handler.on("change",function(e){DND_Setup_Uploader(this.files,'click')});var DND_Setup_Uploader=function(files,action){if(!files.length>1){return}
13
- var formData=new FormData(),object_files=[];$.each(files,function(i,file){if(count_files>options.max_file){return!1}
14
- var progressBarID=createProgressBar(file),has_error=!1;if(file.size>options.max_upload_size){has_error=!0;$('.dnd-upload-details',$('#'+progressBarID)).append('<span class="has-error">'+dnd_cf7_uploader.drag_n_drop_upload.large_file+'</span>')}
15
- count_files++;if(has_error===!1){formData.append('upload-file',file);formData.append('supported_type',options.supported_type);formData.append('size_limit',options.max_upload_size);formData.append('action','dnd_codedropz_upload');formData.append('type',action);var dnd_ajax_upload=$.ajax({url:options.ajax_url,type:form_handler.attr('method'),data:formData,dataType:'json',cache:!1,contentType:!1,processData:!1,xhr:function(){var _xhr=new window.XMLHttpRequest();_xhr.upload.addEventListener("progress",function(event){if(event.lengthComputable){var percentComplete=(event.loaded/event.total);var percentage=parseInt(percentComplete*100);setProgressBar(progressBarID,percentage)}},!1);return _xhr},complete:function(){setProgressBar(progressBarID,100)},success:function(response){if(response.success){if($.isFunction(options.on_success)){options.on_success.call(this,progressBarID,response)}}else{$('.dnd-progress-bar',$('#'+progressBarID)).remove();$('.dnd-upload-details',$('#'+progressBarID)).append('<span class="has-error">'+response.data+'</span>');$('input[type="submit"]',form_handler).removeClass('disabled').prop("disabled",!1)}},error:function(xhr,ajax,thrownError){$('.dnd-progress-bar',$('#'+progressBarID)).remove();$('.dnd-upload-details',$('#'+progressBarID)).append('<span class="has-error">'+options.server_max_error+'</span>');$('input[type="submit"]',form_handler).removeClass('disabled').prop("disabled",!1)}})}})}
16
- $(document).on("click",'.dnd-icon-remove',function(){$(this).parents('.dnd-upload-status').remove();count_files=(count_files-1)});function createProgressBar(file){var upload_handler=$('.codedropz-upload-handler',options_handler),generated_ID='dnd-file-'+Math.random().toString(36).substr(2,9);var fileDetails='<div class="dnd-upload-image"><span class="dnd-icon-blank-file"></span></div>'+'<div class="dnd-upload-details">'+'<span class="name">'+file.name+' <em>('+bytesToSize(file.size)+')</em></span>'+'<a href="javascript:void(0)" title="Remove" class="remove-file"><span class="dnd-icon-remove"></span></a>'+'<span class="dnd-progress-bar"><span></span></span>'+'</div>';upload_handler.after('<div id="'+generated_ID+'" class="dnd-upload-status">'+fileDetails+'</div>');return generated_ID}
17
- function setProgressBar(statusbar,percent){var statusBar=$('.dnd-progress-bar',$('#'+statusbar));if(statusBar.length>0){disableBtn(btnOBJ);progress_width=(percent*statusBar.width()/100);$('span',statusBar).addClass('in-progress').animate({width:progress_width},10).text(percent+'% ');if(percent==100){$('span',statusBar).removeClass('in-progress')}}
18
- return!1}
19
- function bytesToSize(bytes){if(bytes===0)
20
- return'0';kBytes=(bytes/1024);fileSize=(kBytes>=1024?(kBytes/1024).toFixed(2)+'MB':kBytes.toFixed(2)+'KB');return fileSize}
21
- function disableBtn(BtnOJB){if(BtnOJB.length>0){BtnOJB.addClass('disable').prop("disabled",!0)}}}}(jQuery))
1
  /**
2
+ * CodeDropz Uploader v1.2
3
  * Copyright 2018 Glen Mongaya
4
  * CodeDrop Drag&Drop Uploader
5
+ * @version 1.2
6
  * @author CodeDropz, Glen Don L. Mongaya
7
  * @license The MIT License (MIT)
8
  */
9
 
10
  // CodeDropz Drag and Drop Plugin
11
+ !function(e){e.fn.CodeDropz_Uploader=function(a){var d=e.extend({handler:this,color:"#000",background:"",server_max_error:"Uploaded file exceeds the maximum upload size of your server.",max_file:10,text:"Drag & Drop Files Here",separator:"or",button_text:"Browse Files",max_upload_size:"5242880",supported_type:"jpg|jpeg|JPG|png|gif|pdf|doc|docx|ppt|pptx|odt|avi|ogg|m4a|mov|mp3|mp4|mpg|wav|wmv|xls",on_success:""},a);localStorage.setItem("dnd_count_files",1);var r='<div class="codedropz-upload-handler"><div class="codedropz-upload-container"><div class="codedropz-upload-inner"><h3>'+d.text+"</h3><span>"+d.separator+'</span><div class="codedropz-btn-wrap"><a class="cd-upload-btn" href="javascript:void(0)">'+d.button_text+"</a></div></div></div></div>";d.handler.wrapAll('<div class="codedropz-upload-wrapper"></div>');var o=d.handler.parents("form"),n=d.handler.parents(".codedropz-upload-wrapper"),s=e('input[type="submit"]',o);d.handler.after(r),e(".codedropz-upload-handler",n).on("drag dragstart dragend dragover dragenter dragleave drop",function(e){e.preventDefault(),e.stopPropagation()}),e(".codedropz-upload-handler",n).on("dragover dragenter",function(a){e(this).addClass("codedropz-dragover")}),e(".codedropz-upload-handler",n).on("dragleave dragend drop",function(a){e(this).removeClass("codedropz-dragover")}),e("a.cd-upload-btn",n).on("click",function(e){e.preventDefault(),d.handler.val(null),d.handler.click()}),e(".codedropz-upload-handler",n).on("drop",function(e){t(e.originalEvent.dataTransfer.files,"drop")}),d.handler.on("change",function(e){t(this.files,"click")});var t=function(a,r){if(!(!a.length>1)){var s=new FormData,t=dnd_cf7_uploader.drag_n_drop_upload;n.find("span.has-error-msg").remove(),e.each(a,function(a,l){if(localStorage.dnd_count_files>d.max_file)return n.append('<span class="has-error-msg">'+t.max_file_limit.replace("%count%",d.max_file)+"</span>"),!1;var i=function(a){var d=e(".codedropz-upload-handler",n),r="dnd-file-"+Math.random().toString(36).substr(2,9),o='<div class="dnd-upload-image"><span class="dnd-icon-blank-file"></span></div><div class="dnd-upload-details"><span class="name">'+a.name+" <em>("+(s=a.size,0===s?"0":(kBytes=s/1024,fileSize=kBytes>=1024?(kBytes/1024).toFixed(2)+"MB":kBytes.toFixed(2)+"KB",fileSize))+')</em></span><a href="javascript:void(0)" title="Remove" class="remove-file"><span class="dnd-icon-remove"></span></a><span class="dnd-progress-bar"><span></span></span></div>';var s;return d.after('<div id="'+r+'" class="dnd-upload-status">'+o+"</div>"),r}(l),c=!1;if(regex_type=new RegExp("(.*?).("+d.supported_type+")$"),regex_type.test(l.name.toLowerCase())||(e(".dnd-upload-details",e("#"+i)).append('<span class="has-error">'+t.inavalid_type+"</span>"),c=!0),!c&&l.size>d.max_upload_size&&(e(".dnd-upload-details",e("#"+i)).append('<span class="has-error">'+t.large_file+"</span>"),c=!0),localStorage.dnd_count_files=Number(localStorage.dnd_count_files)+1,!1===c){s.append("upload-file",l),s.append("supported_type",d.supported_type),s.append("size_limit",d.max_upload_size),s.append("action","dnd_codedropz_upload"),s.append("type",r);e.ajax({url:d.ajax_url,type:o.attr("method"),data:s,dataType:"json",cache:!1,contentType:!1,processData:!1,xhr:function(){var e=new window.XMLHttpRequest;return e.upload.addEventListener("progress",function(e){if(e.lengthComputable){var a=e.loaded/e.total,d=parseInt(100*a);p(i,d)}},!1),e},complete:function(){p(i,100)},success:function(a){a.success?e.isFunction(d.on_success)&&d.on_success.call(this,i,a):(e(".dnd-progress-bar",e("#"+i)).remove(),e(".dnd-upload-details",e("#"+i)).append('<span class="has-error">'+a.data+"</span>"),e('input[type="submit"]',o).removeClass("disabled").prop("disabled",!1))},error:function(a,r,n){e(".dnd-progress-bar",e("#"+i)).remove(),e(".dnd-upload-details",e("#"+i)).append('<span class="has-error">'+d.server_max_error+"</span>"),e('input[type="submit"]',o).removeClass("disabled").prop("disabled",!1)}})}})}};function p(a,d){var r,o=e(".dnd-progress-bar",e("#"+a));return o.length>0&&((r=s).length>0&&r.addClass("disable").prop("disabled",!0),progress_width=d*o.width()/100,e("span",o).addClass("in-progress").animate({width:progress_width},10).text(d+"% "),100==d&&e("span",o).removeClass("in-progress")),!1}e(document).on("click",".dnd-icon-remove",function(){var a=e(this).parents(".dnd-upload-status");if(e("span.has-error-msg",n).length&&e("span.has-error-msg",n).remove(),a.find("span.has-error").length)return localStorage.dnd_count_files=Number(localStorage.dnd_count_files)-1,a.remove(),!1;1==localStorage.dnd_count_files&&BtnOJB.removeClass("disable").removeAttr("disabled"),e.post(d.ajax_url,{path:a.find('input[type="hidden"]').val(),action:"dnd_codedropz_upload_delete"},function(e){a.remove(),localStorage.dnd_count_files=Number(localStorage.dnd_count_files)-1})})}}(jQuery);
 
 
 
 
 
 
 
 
 
 
assets/js/dnd-upload-cf7.js CHANGED
@@ -20,15 +20,15 @@ jQuery(document).ready(function($){
20
  // Progressbar Object
21
  var progressDetails = $('#' + progressBar, dnd_input_file.parents('.codedropz-upload-wrapper') );
22
 
23
- // If it's complete remove disabled attribute in button
24
  if( $('.in-progress', dnd_input_file.parents('form') ).length === 0 ) {
25
- setTimeout(function(){ $('input[type="submit"]', dnd_input_file.parents('form')).removeAttr('disabled'); }, 1);
26
  }
27
 
28
  // Append hidden input field
29
  progressDetails
30
  .find('.dnd-upload-details')
31
- .append('<span><input type="hidden" name="'+ dnd_input_file.attr('name') +'[]" value="'+ response.data.path +'/'+ response.data.file +'"></span>');
32
  }
33
  });
34
  });
@@ -38,13 +38,13 @@ jQuery(document).ready(function($){
38
  // Reset upload list
39
  if( Cf7myUploadFile.length > 0 ) {
40
  $.each( Cf7myUploadFile, function(){
41
- $('.dnd-upload-status', $('span.' + $(this).attr('name'))).remove();
42
  });
43
  }else {
44
- $('.dnd-upload-status', $('span.' + Cf7myUploadFile.attr('name'))).remove();
45
  }
46
  // Reset count files
47
- count_files=0;
48
  }, false );
49
 
50
  });
20
  // Progressbar Object
21
  var progressDetails = $('#' + progressBar, dnd_input_file.parents('.codedropz-upload-wrapper') );
22
 
23
+ // If it's complete remove disabled attribute in button
24
  if( $('.in-progress', dnd_input_file.parents('form') ).length === 0 ) {
25
+ setTimeout(function(){ $('input[type="submit"]', dnd_input_file.parents('form')).removeAttr('disabled'); }, 1);
26
  }
27
 
28
  // Append hidden input field
29
  progressDetails
30
  .find('.dnd-upload-details')
31
+ .append('<span><input type="hidden" name="'+ dnd_input_file.attr('data-name') +'[]" value="'+ response.data.path +'/'+ response.data.file +'"></span>');
32
  }
33
  });
34
  });
38
  // Reset upload list
39
  if( Cf7myUploadFile.length > 0 ) {
40
  $.each( Cf7myUploadFile, function(){
41
+ $('.dnd-upload-status', $('span.' + $(this).attr('data-name'))).remove();
42
  });
43
  }else {
44
+ $('.dnd-upload-status', $('span.' + Cf7myUploadFile.attr('data-name'))).remove();
45
  }
46
  // Reset count files
47
+ localStorage.dnd_count_files = 1;
48
  }, false );
49
 
50
  });
drag-n-drop-upload-cf7.php CHANGED
@@ -6,7 +6,7 @@
6
  * Description: This simple plugin create Drag & Drop or choose Multiple File upload in your Confact Form 7 Forms.
7
  * Text Domain: dnd-upload-cf7
8
  * Domain Path: /languages
9
- * Version: 1.2.5.0
10
  * Author: Glen Don L. Mongaya
11
  * Author URI: http://codedropz.com
12
  * License: GPL2
@@ -21,7 +21,7 @@
21
  define( 'dnd_upload_cf7', true );
22
 
23
  /** Define plugin Version */
24
- define( 'dnd_upload_cf7_version', '1.2.5.0' );
25
 
26
  /** Define constant Plugin Directories */
27
  define( 'dnd_upload_cf7_directory', untrailingslashit( dirname( __FILE__ ) ) );
6
  * Description: This simple plugin create Drag & Drop or choose Multiple File upload in your Confact Form 7 Forms.
7
  * Text Domain: dnd-upload-cf7
8
  * Domain Path: /languages
9
+ * Version: 1.2.6.0
10
  * Author: Glen Don L. Mongaya
11
  * Author URI: http://codedropz.com
12
  * License: GPL2
21
  define( 'dnd_upload_cf7', true );
22
 
23
  /** Define plugin Version */
24
+ define( 'dnd_upload_cf7_version', '1.2.6.0' );
25
 
26
  /** Define constant Plugin Directories */
27
  define( 'dnd_upload_cf7_directory', untrailingslashit( dirname( __FILE__ ) ) );
inc/dnd-upload-cf7.php CHANGED
@@ -24,6 +24,10 @@
24
  add_action( 'wp_ajax_dnd_codedropz_upload', 'dnd_upload_cf7_upload' );
25
  add_action( 'wp_ajax_nopriv_dnd_codedropz_upload', 'dnd_upload_cf7_upload' );
26
 
 
 
 
 
27
  // Hook mail cf7
28
  add_action('wpcf7_before_send_mail','dnd_cf7_before_send_mail', 30, 1);
29
  add_action('wpcf7_mail_components','dnd_cf7_mail_components', 50, 2);
@@ -61,6 +65,7 @@
61
  'failed_upload' => __('Uploading a file fails for any reason','dnd-upload-cf7'),
62
  'large_file' => __('Uploaded file is too large','dnd-upload-cf7'),
63
  'invalid_type' => __('Uploaded file is not allowed for file type','dnd-upload-cf7'),
 
64
  );
65
 
66
  // return error message based on $error_key request
@@ -100,6 +105,7 @@
100
 
101
  // Prop email
102
  $mail = $wpcf7->prop('mail');
 
103
 
104
  // Default upload path
105
  $simple_path = $upload_dir['baseurl'];
@@ -115,12 +121,20 @@
115
  if( isset( $submitted['posted_data'][$field->name] ) && ! empty( $submitted['posted_data'][$field->name] ) ) {
116
  $files = implode( "\n" . $simple_path . '/' , $submitted['posted_data'][$field->name] );
117
  $mail['body'] = str_replace( "[$field->name]", "\n" . $simple_path .'/'. $files, $mail['body'] );
 
 
 
118
  }
119
  }
120
  }
121
 
122
  // Save the email body
123
  $wpcf7->set_properties( array("mail" => $mail) );
 
 
 
 
 
124
  }
125
 
126
  return $wpcf7;
@@ -204,6 +218,8 @@
204
  'browse' => ( get_option('drag_n_drop_browse_text') ? get_option('drag_n_drop_browse_text') : __('Browse Files','dnd-upload-cf7') ),
205
  'server_max_error' => ( get_option('drag_n_drop_error_server_limit') ? get_option('drag_n_drop_error_server_limit') : dnd_cf7_error_msg('server_limit') ),
206
  'large_file' => ( get_option('drag_n_drop_error_files_too_large') ? get_option('drag_n_drop_error_files_too_large') : dnd_cf7_error_msg('large_file') ),
 
 
207
  )
208
  )
209
  );
@@ -254,8 +270,8 @@
254
 
255
  // Set input type and name
256
  $atts['type'] = 'file';
257
- $atts['name'] = $tag->name;
258
  $atts['multiple'] = 'multiple';
 
259
  $atts['data-type'] = $tag->get_option( 'filetypes','', true);
260
  $atts['data-limit'] = $tag->get_option( 'limit','', true);
261
  $atts['data-max'] = $tag->get_option( 'max-file','', true);
@@ -288,27 +304,14 @@
288
  $name = $tag->name;
289
  $id = $tag->get_id_option();
290
 
291
- $file = isset( $_FILES[$name] ) ? $_FILES[$name] : null;
292
  $multiple_files = ( isset( $_POST[ $name ] ) ? $_POST[ $name ] : null );
293
 
294
- // No file
295
- if ( $file['error'] && UPLOAD_ERR_NO_FILE != $file['error'] && is_null( $multiple_files ) ) {
296
- $result->invalidate( $tag, wpcf7_get_message( 'upload_failed_php_error' ) );
297
- return $result;
298
- }
299
-
300
  // Check if we have files or if it's empty
301
  if( ( is_null( $multiple_files ) || count( $multiple_files ) == 0 ) && $tag->is_required() ) {
302
  $result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
303
  return $result;
304
  }
305
 
306
- //Empty file should be required.
307
- if ( empty( $file['tmp_name'] ) && $tag->is_required() && is_null( $multiple_files ) ) {
308
- $result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
309
- return $result;
310
- }
311
-
312
  return $result;
313
  }
314
 
@@ -470,6 +473,29 @@
470
  die;
471
  }
472
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
473
  // Setup file type pattern for validation
474
  function dnd_upload_cf7_filetypes( $types ) {
475
  $file_type_pattern = '';
@@ -551,6 +577,10 @@
551
  <th scope="row"><?php _e('Invalid file Type','dnd-upload-cf7'); ?></th>
552
  <td><input type="text" name="drag_n_drop_error_invalid_file" class="regular-text" value="<?php echo esc_attr( get_option('drag_n_drop_error_invalid_file') ); ?>" placeholder="<?php echo dnd_cf7_error_msg('invalid_type'); ?>" /></td>
553
  </tr>
 
 
 
 
554
  </table>
555
 
556
  <?php submit_button(); ?>
@@ -570,4 +600,5 @@
570
  register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_failed_to_upload' );
571
  register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_files_too_large' );
572
  register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_invalid_file' );
 
573
  }
24
  add_action( 'wp_ajax_dnd_codedropz_upload', 'dnd_upload_cf7_upload' );
25
  add_action( 'wp_ajax_nopriv_dnd_codedropz_upload', 'dnd_upload_cf7_upload' );
26
 
27
+ // Hook - Ajax Delete
28
+ add_action('wp_ajax_nopriv_dnd_codedropz_upload_delete', 'dnd_codedropz_upload_delete');
29
+ add_action('wp_ajax_dnd_codedropz_upload_delete','dnd_codedropz_upload_delete');
30
+
31
  // Hook mail cf7
32
  add_action('wpcf7_before_send_mail','dnd_cf7_before_send_mail', 30, 1);
33
  add_action('wpcf7_mail_components','dnd_cf7_mail_components', 50, 2);
65
  'failed_upload' => __('Uploading a file fails for any reason','dnd-upload-cf7'),
66
  'large_file' => __('Uploaded file is too large','dnd-upload-cf7'),
67
  'invalid_type' => __('Uploaded file is not allowed for file type','dnd-upload-cf7'),
68
+ 'max_file_limit' => __('Note : Some of the files are not uploaded ( Only %count% files allowed )','dnd-upload-cf7'),
69
  );
70
 
71
  // return error message based on $error_key request
105
 
106
  // Prop email
107
  $mail = $wpcf7->prop('mail');
108
+ $mail_2 = $wpcf7->prop('mail_2');
109
 
110
  // Default upload path
111
  $simple_path = $upload_dir['baseurl'];
121
  if( isset( $submitted['posted_data'][$field->name] ) && ! empty( $submitted['posted_data'][$field->name] ) ) {
122
  $files = implode( "\n" . $simple_path . '/' , $submitted['posted_data'][$field->name] );
123
  $mail['body'] = str_replace( "[$field->name]", "\n" . $simple_path .'/'. $files, $mail['body'] );
124
+ if( $mail_2['active'] ) {
125
+ $mail_2['body'] = str_replace( "[$field->name]", "\n" . $simple_path .'/'. $files, $mail_2['body'] );
126
+ }
127
  }
128
  }
129
  }
130
 
131
  // Save the email body
132
  $wpcf7->set_properties( array("mail" => $mail) );
133
+
134
+ // if mail 2
135
+ if( $mail_2['active'] ) {
136
+ $wpcf7->set_properties( array("mail_2" => $mail_2) );
137
+ }
138
  }
139
 
140
  return $wpcf7;
218
  'browse' => ( get_option('drag_n_drop_browse_text') ? get_option('drag_n_drop_browse_text') : __('Browse Files','dnd-upload-cf7') ),
219
  'server_max_error' => ( get_option('drag_n_drop_error_server_limit') ? get_option('drag_n_drop_error_server_limit') : dnd_cf7_error_msg('server_limit') ),
220
  'large_file' => ( get_option('drag_n_drop_error_files_too_large') ? get_option('drag_n_drop_error_files_too_large') : dnd_cf7_error_msg('large_file') ),
221
+ 'inavalid_type' => ( get_option('drag_n_drop_error_invalid_file') ? get_option('drag_n_drop_error_invalid_file') : dnd_cf7_error_msg('invalid_type') ),
222
+ 'max_file_limit' => ( get_option('drag_n_drop_error_max_file') ? get_option('drag_n_drop_error_max_file') : dnd_cf7_error_msg('max_file_limit') ),
223
  )
224
  )
225
  );
270
 
271
  // Set input type and name
272
  $atts['type'] = 'file';
 
273
  $atts['multiple'] = 'multiple';
274
+ $atts['data-name'] = $tag->name;
275
  $atts['data-type'] = $tag->get_option( 'filetypes','', true);
276
  $atts['data-limit'] = $tag->get_option( 'limit','', true);
277
  $atts['data-max'] = $tag->get_option( 'max-file','', true);
304
  $name = $tag->name;
305
  $id = $tag->get_id_option();
306
 
 
307
  $multiple_files = ( isset( $_POST[ $name ] ) ? $_POST[ $name ] : null );
308
 
 
 
 
 
 
 
309
  // Check if we have files or if it's empty
310
  if( ( is_null( $multiple_files ) || count( $multiple_files ) == 0 ) && $tag->is_required() ) {
311
  $result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
312
  return $result;
313
  }
314
 
 
 
 
 
 
 
315
  return $result;
316
  }
317
 
473
  die;
474
  }
475
 
476
+ // Delete file
477
+ function dnd_codedropz_upload_delete() {
478
+ if( get_option('drag_n_drop_mail_attachment') == 'yes' ) {
479
+ $upload_dir = wp_upload_dir();
480
+ $sub_dir = '/';
481
+
482
+ // If media organized by year.
483
+ if( get_option('uploads_use_yearmonth_folders') ) {
484
+ $sub_dir = '/wp_dndcf7_uploads' . dirname( $upload_dir['subdir'] ) . '/';
485
+ }
486
+
487
+ // Make sure path is set
488
+ if( isset( $_POST['path'] ) && ! empty( $_POST['path'] ) ) {
489
+ $file_path = $upload_dir['basedir'] . $sub_dir . trim( $_POST['path'] );
490
+ if( file_exists( $file_path ) ){
491
+ wp_delete_file( $file_path );
492
+ wp_send_json_success( 'File deleted!' );
493
+ }
494
+ }
495
+ }
496
+ die;
497
+ }
498
+
499
  // Setup file type pattern for validation
500
  function dnd_upload_cf7_filetypes( $types ) {
501
  $file_type_pattern = '';
577
  <th scope="row"><?php _e('Invalid file Type','dnd-upload-cf7'); ?></th>
578
  <td><input type="text" name="drag_n_drop_error_invalid_file" class="regular-text" value="<?php echo esc_attr( get_option('drag_n_drop_error_invalid_file') ); ?>" placeholder="<?php echo dnd_cf7_error_msg('invalid_type'); ?>" /></td>
579
  </tr>
580
+ <tr valign="top">
581
+ <th scope="row"><?php _e('Max File Limit','dnd-upload-cf7'); ?></th>
582
+ <td><input type="text" name="drag_n_drop_error_max_file" class="regular-text" value="<?php echo esc_attr( get_option('drag_n_drop_error_max_file') ); ?>" placeholder="" /><p class="description">Example: `Note : Some of the files are not uploaded ( Only %count% files allowed )`</p></td>
583
+ </tr>
584
  </table>
585
 
586
  <?php submit_button(); ?>
600
  register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_failed_to_upload' );
601
  register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_files_too_large' );
602
  register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_invalid_file' );
603
+ register_setting( 'drag-n-drop-upload-file-cf7', 'drag_n_drop_error_max_file' );
604
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Donate link : http://codedropz.com/donation
3
  Tags: drag and drop, contact form 7, ajax uploader, multiple file, upload, contact form 7 uploader
4
  Requires at least: 3.0.1
5
  Tested up to: 5.2
6
- Stable tag: 1.2.5.0
7
  Requires PHP: 5.2.4
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -14,7 +14,7 @@ Drag and Drop Uploader a simple Wordpress plugin extension for Contact Form 7, t
14
 
15
  Here's a little demo [here](http://codedropz.com/contact).
16
 
17
- = Features =
18
 
19
  * File Type Validation
20
  * File Size Validation
@@ -27,6 +27,26 @@ Here's a little demo [here](http://codedropz.com/contact).
27
  * Cool Progress Bar
28
  * Browser Compatability
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  == Frequently Asked Questions ==
31
 
32
  = How can I send feedback or get help with a bug? =
@@ -39,7 +59,7 @@ To limit file size in `multiple file upload` field generator under Contact Form
39
 
40
  = How can I limit the number of files in my Upload? =
41
 
42
- You can limit the number of files in your file upload by adding this parameter `max-file:3` to your shortcode :
43
 
44
  Example: (limit - 3): `[mfile upload-file-344 max-file:3]`
45
 
@@ -85,6 +105,18 @@ To install this plugin see below:
85
 
86
  == Changelog ==
87
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  = 1.2.5.0 =
89
  * Fixed - Please Update to 1.2.5.0 to fixed disable button issue.
90
 
@@ -106,7 +138,7 @@ To install this plugin see below:
106
 
107
  = 1.2.2 =
108
  * Add - Create admin settings where you can manage or change text in your uploading area. It's under 'contacts' > 'Drag and Drop'.
109
- * New - Empty or Clear attachment file when Contact Form successfully send.
110
  * Fixes - Fixed remove item bugs when file is greater than file limit.
111
  * Fixes - Changed 'icon-moon' fonts to avoid conflict with the other themes.
112
  * New - Added text domain for language translations.
3
  Tags: drag and drop, contact form 7, ajax uploader, multiple file, upload, contact form 7 uploader
4
  Requires at least: 3.0.1
5
  Tested up to: 5.2
6
+ Stable tag: 1.2.6.0
7
  Requires PHP: 5.2.4
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
14
 
15
  Here's a little demo [here](http://codedropz.com/contact).
16
 
17
+ ### Features
18
 
19
  * File Type Validation
20
  * File Size Validation
27
  * Cool Progress Bar
28
  * Browser Compatability
29
 
30
+ ### Premium Features
31
+
32
+ Checkout available features on PRO version.
33
+
34
+ * Image Preview
35
+ * Auto Delete Files - After Submission
36
+ * Zip Files
37
+ * Save Files To Media Library
38
+ * Change Upload Directory
39
+ - Generated Name (Timestamp)
40
+ - Random Folder
41
+ - By User
42
+ - Custom Folder
43
+ * Email Attachment as Links or Zip Files
44
+ * Improved Security
45
+ * Optimized Code and Performance
46
+ * 1 Month Premium Support
47
+
48
+ You can get [PRO Version here](https://www.codedropz.com/purchase-plugin/)!
49
+
50
  == Frequently Asked Questions ==
51
 
52
  = How can I send feedback or get help with a bug? =
59
 
60
  = How can I limit the number of files in my Upload? =
61
 
62
+ You can limit the number of files in your file upload by adding this parameter `max-file:3` to your shortcode :
63
 
64
  Example: (limit - 3): `[mfile upload-file-344 max-file:3]`
65
 
105
 
106
  == Changelog ==
107
 
108
+ = 1.2.6.0 =
109
+ * Fixed - Allow to upload file with the same filename.
110
+ * Fixed - Can't upload image after delecting (https://wordpress.org/support/topic/cant-upload-image-after-deleting-it/)
111
+ * Fixed - Max-file issue (https://wordpress.org/support/topic/max-file-issue/)
112
+ * Added - a note message when file reached the max-file Limit ( "To inform user that some of the files are not uploaded" ).
113
+ * Added - Better Ajax deletion ( Remove files from the server - Only if `Send As Attachment` is checked )
114
+ * Optimized - Form send loading time has been optimized ( Improved loading time for large attachment )
115
+ * Fixed - Bug reported by @palychwp " `remove file still send sends with the form` (https://wordpress.org/support/topic/file-uploading-is-working-incorrect/)
116
+ * Added - Validate File/Attachment first before the upload start ("some says it's frustating :)")
117
+ - (PHP or Server side validation still there for security and better validation)
118
+ * Improved file counting via `LocalStorage` instead of Global variable.
119
+
120
  = 1.2.5.0 =
121
  * Fixed - Please Update to 1.2.5.0 to fixed disable button issue.
122
 
138
 
139
  = 1.2.2 =
140
  * Add - Create admin settings where you can manage or change text in your uploading area. It's under 'contacts' > 'Drag and Drop'.
141
+ * New - Empty or Clear attachment file when Contact Form successfully send.
142
  * Fixes - Fixed remove item bugs when file is greater than file limit.
143
  * Fixes - Changed 'icon-moon' fonts to avoid conflict with the other themes.
144
  * New - Added text domain for language translations.