jak zrobić pętlę w php i złapać w jquery?
<script type="text/javascript">
<!--
$(document).ready(function() {
var options = {
target: '<?php echo '#message'.$i ?>', //Div tag where content info will be loaded in
url:'files.php', //The php file that handles the file that is uploaded
beforeSubmit: function() {
$('<?php echo '#uploader'.$i ?>').html('<img src="ajax-loader.gif" border="0" />'); //Including a preloader, it loads into the div tag with id uploader
},
success: function() {
//Here code can be included that needs to be performed if Ajax request was successful
$('<?php echo '#uploader'.$i ?>').html('');
}
};
$('<?php echo '#upload'.$i ?>').submit(function() {
$(this).ajaxSubmit(options);
return false;
});
});
//-->
</script>
i php pętla
<?php
for ($i = 1; $i <= 5; $i++) { ?>
<form name="<?php echo 'upload'.$i ?>" id="<?php echo 'upload'.$i ?>" action="#" method="POST" enctype="multipart/form-data">
<table cellpadding="4" cellspacing="4" border="0">
<tr>
<td class="fieldLabel" nowrap>File:</td>
<td nowrap><input type="file" name="fileToUpload" id="fileToUpload" />
<input type="submit" id="uploadFile" value="Wczytaj plik" /></td>
</tr>
<tr>
<div id="<?php echo 'message'.$i ?>"></div>
<div id="<?php echo 'uploader'.$i ?>"></div>
</tr>
</table>
</form>
<?php }?>