2012-02-01 16:47:09 +00:00

65 lines
1.6 KiB
PHTML

<div>
<h2>Intégration d'un fichier</h2>
<p>Taille maximale d'un fichier : <?=$this->filesize?></p>
<form enctype="multipart/form-data" name="sendfile" action="<?=$this->url(array('controller'=>'envoi','action'=>'fileupload'))?>" method="post">
<input type="hidden" name="APC_UPLOAD_PROGRESS" id="key" value="<?=uniqid()?>"/>
<div class="fieldgrp">
<label>Sélection d'un client</label>
<div class="field">
<select name="client">
<?php foreach ($this->clients as $client) {?>
<option value="<?=$client->id?>"><?=$client->nom?></option>
<?php }?>
</select>
</div>
</div>
<div class="fieldgrp">
<label>Référence</label>
<div class="field"><input type="text" name="ref" /></div>
</div>
<div class="fieldgrp">
<label>Fichier</label>
<div class="field">
<input type="file" id="fichier" name="fichier"/>
<input type="submit" value="Envoi"/>
<div id="progressbar"></div>
<div id="output"></div>
</div>
</div>
</form>
</div>
<script>
var timer;
$('form[name=sendfile]').ajaxForm({
beforeSubmit: function() {
timer = setInterval(checkProgress,200);
$('#progressbar').reportprogress(0);
$('#output').html('Envoi en cours...');
},
success: function(data) {
clearInterval(timer);
$('#progressbar').remove();
$('#output').html('<strong>' + data + '</strong>');
}
});
function checkProgress() {
$.get('<?=$this->url(array('controller'=>'envoi', 'action'=>'fileprogress'))?>',
{key: $('#key').val()}, function(data) {
var percent = data.current/data.total*100;
$('#progressbar').reportprogress(percent);
}, 'json');
}
</script>