Post by omnicubed2 » Thu Mar 08, 2018 6:27 am

Opencart 2.3.0.2

Hello,
I found a free Contact Form - Upload File (VQMOD/XML) see below. It functions perfectly! But i would like to make it so people can upload multiple files and i dont know what code to change/duplicate. I am okay with having multiple upload buttons or a single button that lets them upload multiple files, whichever is easier.

What do i need to change in the code to make this happen? Any help would be greatly appreciated as I am a newbie coder and haven't been able to get it to work, i can get the button but it wont send the other files.

<!-- Created using vQmod XML Generator by UKSB - http://uksb.github.com/vqgen/ //-->
<modification>
<id><![CDATA[ContactUpload]]></id>
<version><![CDATA[2.3.0.2]]></version>
<vqmver><![CDATA[2.6.1]]></vqmver>
<author><![CDATA[atom:kft2046@gmail.com]]></author>
<file name="catalog/view/theme/*/template/information/contact.tpl">
<operation errot="skip">
<search position="before" error="log"><![CDATA[<?php echo $captcha; ?>
]]></search>
<add><![CDATA[
<div class="form-group">
<label class="col-sm-2 control-label" for="input-file">File 1</label>
<div class="col-sm-5">
<img id="upimg">
<button type="button" id="button-upload" data-loading-text="Uploading.." class="btn btn-default btn-block"><i class="fa fa-upload"></i> <?php echo 'Upload'; ?></button>
<input type="hidden" name="file" value="" id="file">
</div>
</div>
]]></add>
</operation>

<operation error="skip">
<search position="before"><![CDATA[<?php echo $footer; ?>]]></search>
<add><![CDATA[

<script>
$('button[id^=\'button-upload\']').on('click', function() {
var node = this;

$('#form-upload').remove();

$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');

$('#form-upload input[name=\'file\']').trigger('click');

timer = setInterval(function() {
if ($('#form-upload input[name=\'file\']').val() != '') {
clearInterval(timer);

$.ajax({
url: 'index.php?route=tool/upload',
type: 'post',
dataType: 'json',
data: new FormData($('#form-upload')[0]),
cache: false,
contentType: false,
processData: false,
beforeSend: function() {
$(node).button('loading');
},
complete: function() {
$(node).button('reset');
},
success: function(json) {
$('.text-danger').remove();

if (json['error']) {
$(node).parent().find('input').after('<div class="text-danger">' + json['error'] + '</div>');
}

if (json['success']) {
alert(json['success']);

$(node).parent().find('input').attr('value', json['code']);
$(node).parent().find('img').attr('src', json['image']);
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
}, 500);
});
</script>

]]></add>
</operation>

</file>

<file name="catalog/controller/information/contact.php">
<operation errot="skip">
<search position="replace" error="log"><![CDATA[$mail->send();
]]></search>
<add><![CDATA[
if($this->request->post['file']){
$this->load->model('tool/upload');
$upload_info = $this->model_tool_upload->getUploadByCode($this->request->post['file']);
$phyname = DIR_UPLOAD.$upload_info['filename'];
$temp_name = DIR_UPLOAD.$upload_info['name'];
copy($phyname,$temp_name);
$mail->AddAttachment($temp_name);
}

$mail->send();
if(isset($temp_name)){
unlink( $temp_name );
}
]]></add>
</operation>

</file>

<file name="catalog/controller/tool/upload.php">
<operation errot="skip">
<search position="after" error="log"><![CDATA[ $json['success'] = $this->language->get('text_upload');
]]></search>
<add><![CDATA[
$phyname = DIR_UPLOAD . $file;
$temp_name = DIR_IMAGE . $filename;
copy($phyname,$temp_name);
$this->load->model('tool/image');
$image = $this->model_tool_image->resize($filename, 120, 120);
unlink($temp_name);
$json['image'] = $image;
]]></add>
</operation>

</file>

</modification>

Link to original opencart resource:
https://www.opencart.com/index.php?rout ... sort=price

Newbie

Posts

Joined
Sat Nov 04, 2017 5:34 am

Post by IP_CAM » Fri Mar 09, 2018 1:09 pm

Well, one solution would be, to tell the customers, to first pack their images
into a ZIP file, by use of the extension linked below. It's, what exists for your Version,
and possibly the only way, to get this done for a relatively cheap price.
Contact us form Pro OC2x
https://www.opencart.com/index.php?rout ... n_id=32812
Image
---
A Demo is here:
http://ocextension.apptiko.com/index.ph ... on/contact
---
Another possible Solution:
Contact Us Ultimate
https://www.opencart.com/index.php?rout ... n_id=28364
Image
And here:
Contact Form Builder
- file upload
○ Default upload button
○ Drag and Drop upload area
https://www.opencart.com/index.php?rout ... n_id=32828
---
Good Luck
Ernie

Attachments

upload_zip_file.jpg

upload_zip_file.jpg (25.2 KiB) Viewed 659 times


Ernie's OpenCart v.1.5.6.5 LIGHT + V-Pro + OpenShop Admin v.1.75 Test Sites
http://www.bigmax.ch - http://www.opencart.li/shop/ - http://www.velomech.ch/cart/
Image


User avatar
Guru Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland
Who is online

Users browsing this forum: No registered users and 5 guests