Bonsoir
je voulais récupérer un fichier avec jquery
voici mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 file_data = $('#scan').val(); var form_data = new FormData(); form_data.append('file', file_data); $.ajax({ url: 'save.php', dataType: 'text', cache: false, contentType: false, processData: false, data: form_data, type: 'post', success: function(data){ alert(data); // display response from the PHP script, if any }, error : function(XMLHttpRequest, textStatus, errorThrown) {alert(errorThrown) } });
Code HTML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 <div> <input type="file" id="scan" name="scan" accept="application/pdf" ><br> </div> <div> <input type="submit" value="Valider" disabled name="enregistrer" id="enregistrer"> </div>
ma page save.php
Code PHP : Sélectionner tout - Visualiser dans une fenêtre à part echo $_FILES['file']['name'];
mais ça ne donne rien
Partager