
Upload Multiple files, jquery ajax
Hi guys,
I have a form to upload multiple files.
With a jquery ajax action I submit the files:"
<script>
$(document).ready(function(){
$('#BijlageAanmakenForm').submit(function(){
$("#BijlageAanmaken").replaceWith("<img src='{% file_asset_url 'spin.gif' %}' height='35' width='35' id='spinner'/>")
var formData = new FormData($(this)[0]);
var zorgaanbiederid = {{objzorgaanbieder.id}};
var hoofdmap = {{hoofdmap}};
var submap = {{submap}};
$.ajax({
type: $(this).attr('method'),
url: $(this).attr('action'),
data: formData,
cache: false,
contentType: false,
processData: false,
async: false
})
.done(function(){
$("#editzorgaanbieder"+zorgaanbiederid).load("/crmversie2/lijsten/bijlagen_nieuw?zorgaanbiederid="+zorgaanbiederid, function() {
$("#submappen"+zorgaanbiederid).load("/crmversie2/lijsten/submappen?zorgaanbiederid="+zorgaanbiederid+"&hoofdmap="+hoofdmap, function() {
$("#submapbijlagen"+zorgaanbiederid).load("/crmversie2/lijsten/submapbijlagen?zorgaanbiederid="+zorgaanbiederid+"&submap="+submap+"&hoofdmap="+hoofdmap);
$("#buttonhoofdmap"+hoofdmap).addClass('active');
$("#buttonsubmap"+submap).addClass('active');
})
});
})
.fail(function() {
alert( "Posting failed." );
});
return false;
});
});
</script>
In the action get the collection file. I loop through the collection and get the filename (text expression, fetch(var:fileitem,"filename","")).
But I do not know how the get the file. In the initial collection (file) it seems that he url is not loaded. In the fileitem I see an item called TempFile. But when I try to get this (url expression, fetch(var:fileitemthis,"tempfile","")), the error "Error: InvalidInputError: Undefined method `has_key?' for # (variable 'tempfile')" occurs.
So I am stuck. Basically all I want to do is give my customer the option to upload multiple files at once, and then reload that section of the page.
Can anyone help me with this?
Corné
Hi guys,
I have a form to upload multiple files.
With a jquery ajax action I submit the files:"
<script>
$(document).ready(function(){
$('#BijlageAanmakenForm').submit(function(){
$("#BijlageAanmaken").replaceWith("<img src='{% file_asset_url 'spin.gif' %}' height='35' width='35' id='spinner'/>")
var formData = new FormData($(this)[0]);
var zorgaanbiederid = {{objzorgaanbieder.id}};
var hoofdmap = {{hoofdmap}};
var submap = {{submap}};
$.ajax({
type: $(this).attr('method'),
url: $(this).attr('action'),
data: formData,
cache: false,
contentType: false,
processData: false,
async: false
})
.done(function(){
$("#editzorgaanbieder"+zorgaanbiederid).load("/crmversie2/lijsten/bijlagen_nieuw?zorgaanbiederid="+zorgaanbiederid, function() {
$("#submappen"+zorgaanbiederid).load("/crmversie2/lijsten/submappen?zorgaanbiederid="+zorgaanbiederid+"&hoofdmap="+hoofdmap, function() {
$("#submapbijlagen"+zorgaanbiederid).load("/crmversie2/lijsten/submapbijlagen?zorgaanbiederid="+zorgaanbiederid+"&submap="+submap+"&hoofdmap="+hoofdmap);
$("#buttonhoofdmap"+hoofdmap).addClass('active');
$("#buttonsubmap"+submap).addClass('active');
})
});
})
.fail(function() {
alert( "Posting failed." );
});
return false;
});
});
</script>
In the action get the collection file. I loop through the collection and get the filename (text expression, fetch(var:fileitem,"filename","")).
But I do not know how the get the file. In the initial collection (file) it seems that he url is not loaded. In the fileitem I see an item called TempFile. But when I try to get this (url expression, fetch(var:fileitemthis,"tempfile","")), the error "Error: InvalidInputError: Undefined method `has_key?' for # (variable 'tempfile')" occurs.
So I am stuck. Basically all I want to do is give my customer the option to upload multiple files at once, and then reload that section of the page.
Can anyone help me with this?
Corné
-
No ideas, folks?