UI dialog post data et file upload
Bonjour,
j'ai un formulaire dans une fenetre UI dialog qui s'enregistre correctement.
Je souhaiterais ajouter dans ce formulaire un champ de type file.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| <form id="form_photo" method="post" enctype="multipart/form-data">
<input name="id" type="hidden" value="">
<input name="position" id="position" type="hidden" value="3">
<table class="table_form">
<tr>
<td>Titre <span class="required">*</span></td>
<td>
<input name="titre" type="text" value="">
</td>
</tr>
<tr>
<td>Photo</td>
<td>
<input name="fichier" id="fichier" type="file"/>
</td>
</tr>
<tr>
<td>Suivi par <span class="required">*</span></td>
<td>
<select name='suivi_par' id='suivi_par'><option value='0'>Choisissez...</option>
<option value='1'selected >Arociel Florence</option>
<option value='2' >NOM PRENOM</option></select> </td>
</tr>
<tr>
<td>Etat <span class="required">*</span></td>
<td>
<select name='id_etat_photos' id='id_etat_photos'><option value='0'>Choisissez...</option>
<option value='1' >Diffusée</option>
<option value='2' >Non diffusée</option></select> </td>
</tr>
</table>
</form> |
Actuellement, j'ai une fonction jquery pour poster les données :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| function savePhoto()
{
//envoie le formulaire en ajax, et evalue le retour
app.wait();
var $dialog = $(this);
app.ajax({
type: "post",
url: "app/structures/photos/gestion.php",
data : $("#form_photo").serialize(),
success: function(data, status, rsp) {
app.unwait();
app.evalScripts(data, $dialog);
}
});
} |
Habituellement, j'utilise le plugin "upload" tout seul, je ne sais pas comment faire fusionner à la fois le post du formulaire et le post du fichier dans le meme appel ajax.
ci-dessous le code de l'upload
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| $('#fichier'). upload('ajax.php',{
type: "ajout_photo_structure",
id: data.id
position: data.position
},function ( data ){
//alert ( data.position );
if ( data. status === 0 )
alert ( "Le téléchargement a échoué." ) ;
else{
//window.location.href = page_refresh;//refresh de la page
}
},"json") ; |
Est-ce que vous sauriez de quelle manière je peux faire les deux ?