I'm trying to make a script for Image Download, by Ajax. It can be one or several. As you can see in JS, it has a each
function that looks for the selected images in the system.
Hence, I call Ajax to take the Photo ID as a parameter so that I can search the database, find the address of the photo and download it.
The code returns the encoded image instead of downloading. What do I need to change? Do I need to use AJAX?
// Download de Imagens
$("#download").click(function(){
var ids = '';
$("input[name='foto[]']:checked").each(function(){
ids = $(this).val() + ',' + ids;
});
ids = ids.substr(0,ids.length-1);
$.ajax({
url: urlBase + '/portfolio/download/',
cache: false,
type: "POST",
responseType: 'blob',
data: {ids:ids}
});
});
# Download de Imagens
public function anyDownload(){
$ids = Input::get('ids');
$imagem = GaleriaProjeto::find($ids);
$headers = array(
'Content-Type: image/jpg',
);
return Response::download(URL::to('/img/portfolio/'.$imagem->imagem, $imagem->imagem, $headers));
}