Bonjour
Lorsque j'affiche le code source de ma page html d'un fichier uplodé j'ai ces alertes alors que tout s'effectue correctement:
le code analysé -> $_FILES des 2 "print_r"
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 Array ( ) <br /> <b>Warning</b>: Undefined array key "pdf" in <b>C:\xampp\htdocs\marche\gpx\ressources\serveur\FonctionsServeur.php</b> on line <b>25</b><br /> <br /> <b>Warning</b>: Undefined array key "pdf" in <b>C:\xampp\htdocs\marche\gpx\ressources\serveur\FonctionsServeur.php</b> on line <b>26</b><br /> <br /> <b>Warning</b>: Trying to access array offset on value of type null in <b>C:\xampp\htdocs\marche\gpx\ressources\serveur\FonctionsServeur.php</b> on line <b>26</b><br /> <br /> <b>Warning</b>: Undefined array key "pdf" in <b>C:\xampp\htdocs\marche\gpx\ressources\serveur\FonctionsServeur.php</b> on line <b>27</b><br /> <br /> <b>Warning</b>: Trying to access array offset on value of type null in <b>C:\xampp\htdocs\marche\gpx\ressources\serveur\FonctionsServeur.php</b> on line <b>27</b><br /> <br /> <b>Deprecated</b>: move_uploaded_file(): Passing null to parameter #1 ($from) of type string is deprecated in <b>C:\xampp\htdocs\marche\gpx\ressources\serveur\FonctionsServeur.php</b> on line <b>28</b><br />
le code d'acquisition du fichier, $type est bien égal à "pdf"
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 Array ( [pdf] => Array ( [name] => poeme_hewaien.pdf [full_path] => poeme_hewaien.pdf [type] => application/pdf [tmp_name] => C:\xampp\tmp\phpFBFA.tmp [error] => 0 [size] => 1384535 ) ) Array ( [name] => poeme_hewaien.pdf [full_path] => poeme_hewaien.pdf [type] => application/pdf [tmp_name] => C:\xampp\tmp\phpFBFA.tmp [error] => 0 [size] => 1384535 )
Je suis un peu perdu si vous pouviez m'aiguiller merci.
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
17
18 //Téléchargement fichier function upload($path,$type){ if($type == 'gpx' || $type == 'png' || $type == 'pdf' || $type == 'xlsx'){ print_r($_FILES); print_r($_FILES[$type]); $fichier = $_FILES[$type]['name']; $temp_name = $_FILES[$type]['tmp_name']; if(move_uploaded_file($temp_name, $path."/".$fichier)){ rename($path."/".$fichier, str_replace("_","-",$path."/".$fichier)); $info = "Fichier enregistré:".$fichier; }else{ $info = "Enregistrement Nok";} } else{ $info = "Enregistrement Nok";} return $info; }







Répondre avec citation
Partager