Answer the question
In order to leave comments, you need to log in
How to upload images to joomla using ajax?
I need to load the image using Ajax, but the problem is that even if I do not display anything in the module function, a copy of the page is returned.
js code:
function uploadServer($el) {
var fileUpload = $el.get(0);
var file = fileUpload.files[0];
var url;
if (file) {
var data = new FormData();
data.append('image', file);
var request = {
'option': 'com_ajax',
'module': 'constructor',
'method': 'uplodeImage',
'val' : data,
'format': 'raw',
};
console.log(request);
$.ajax({
async: false,
type: 'post',
cache: false,
contentType:false,
processData:false,
data: request,
success: function (response) {
url = response;
}
}).done(function(response){
url = response;
});
}
$('#debug').html(url);
return url;
}
class modConstructorHelper
{
// Загрузка изображений во временную папку
public static function uplodeImage() {
jimport('joomla.application.module.helper');
jimport('joomla.application.input.files');
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question