Good afternoon, I'm using the following code to upload images:
function uploadImage($form){
$form.find('.progress-bar')
.removeClass('progress-bar-success')
.removeClass('progress-bar-danger');
var formdata = new FormData($form[0]); //formelement
var request = new XMLHttpRequest();
//progress event...
request.upload.addEventListener('progress',function(e){
$('.progress').removeClass('hidden');
var percent = Math.round(e.loaded/e.total * 100);
$form.find('.progress-bar').width(percent+'%').html(percent+'%');
});
//progress completed load event
request.addEventListener('load',function(e){
$('.progress').removeClass('active');
$form.find('.progress-bar').addClass('progress-bar-success').html('Upload completo');
});
request.open('post', 'server.php');
request.send(formdata);
}
the file server.php
contains:
<?php
foreach ($_FILES as $name => $file) {
$tmp_file = $file['tmp_name'];
$filename = $file['name'];
move_uploaded_file($tmp_file, 'uploads_folder/'. $name.$_POST['categoria_nome'].'.jpg');
}
return true;
? >
I would like to know how do I get the return
of the server.php
file in the upload function?