Hallo an alle,
ich benutze folgendes Plugin: https://github.com/blueimp/jQuery-File-Upload
Ich würde nun gerne zum Upload Formular (habe ich bereits gemacht) Felder hinzufügen und anschließend das Formular auswerten und die hochgeladenen Bilder bzw. deren Links in der Email ausgeben.
Habe mit natürlich schon das hier angesehen aber bei mir klappt es leider nicht…
https://github.com/blueimp/jQuery-File-Upload/wiki/How-to-submit-additional-form-data
Relevanter Code:
[CODE]jQuery(function () {
‚use strict‘;
// Initialize the jQuery File Upload widget:
jQuery('#fileupload').fileupload({
url: '<?php print(admin_url('admin-ajax.php'));?>',
});
// Enable iframe cross-domain access via redirect option:
jQuery('#fileupload').fileupload(
'option',
'redirect',
window.location.href.replace(
/\/[^\/]*$/,
<?php
$absoluteurl=str_replace(home_url(),'',JQHFUPLUGINDIRURL);
print("'".$absoluteurl."cors/result.html?%s'");
?>
)
);
if(jQuery('#fileupload')) {
// Load existing files:
jQuery('#fileupload').addClass('fileupload-processing');
var formData = jQuery('#fileupload').serializeArray();
// Load existing files:
jQuery.ajax({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: jQuery('#fileupload').fileupload('option', 'url'),
data : {action: "load_ajax_function"},
acceptFileTypes: /(\.|\/)(<?php print(get_option('jqhfu_accepted_file_types')); ?>)$/i,
dataType: 'json',
formData: {example: 'test'},
context: jQuery('#fileupload')[0]
}).always(function () {
jQuery(this).removeClass('fileupload-processing');
}).done(function (result) {
jQuery(this).fileupload('option', 'done')
.call(this, jQuery.Event('done'), {result: result});
}).on('fileuploadsubmit', function (e, data) {
data.formData = data.context.find(':input').serializeArray();
});;
}
});[/CODE]
UploadHandler.php
[PHP] protected function handle_form_data($file, $index) {
mail('foo@example.de', 'Mein Betreff', 'Test');
}[/PHP]
Leider kommt keine Mail an.
Habe auch schon anderes versucht aber dann wird immer eine Mail nach jedem Upload gesendet.
Ich habe in dem Formular auch noch einen Button integriert und nachdem dieser gedrückt wird soll die Mail mit den Daten versendet werden also sozusagen.
Versuche es nun schon sehr lange aber es klappt einfach nicht wie gewünscht.
Jemand Tipps?
Formular:
[HTML]
Add files…
Start upload
Cancel upload
Delete
Alle auswählen
[/HTML]
Falls es wichtig ist das ganze ist in Wordpress umgesetzt aber in Wirklichkeit ist es eh das selbe.
Grüße, maria1