Carica immagini sul server

<?php $target_path1 = "uploads/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path1 = $target_path1 . basename( $_FILES['uploaded_file']['name']); if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $target_path1)) { echo "The first file ". basename( $_FILES['uploaded_file']['name'])."has been uploaded."; } else { echo "There was an error uploading the file, please try again!"; echo "filename: " . basename( $_FILES['uploaded_file']['name']); echo "target_path: " .$target_path1; } ?> 

questo ha 3 errori

Avviso: indice non definito: upload_file in D: \ anddev \ project \ web \ upload_test \ upload_media_test.php sulla linea 5

Avviso: indice non definito: upload_file in D: \ anddev \ project \ web \ upload_test \ upload_media_test.php sulla linea 6

Avviso: indice non definito: upload_file in D: \ anddev \ project \ web \ upload_test \ upload_media_test.php sulla linea 11

Come posso risolvere questo codice?

Aggiungi sempre il segno di spunta per assicurarti di ricevere effettivamente qualcosa,

Puoi utilizzare is_uploaded_file Provalo in questo modo:

 <?php if(is_uploaded_file($_FILES['uploaded_file']['tmp_name']){ //we got something, set it up $target_path1 = "uploads/"; $file = basename( $_FILES['uploaded_file']['name']); $full_path = $target_path1.$file; //perform the upload if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $full_path)) { echo "The first file ".$file." has been uploaded."; } else { echo "There was an error uploading the file, please try again!"; echo "filename: " . $file; } }else{ echo "Nothing was uploaded"; } ?> 

mettere:

 <?php var_dump($_FILES); exit; 

solo all'inizio di un file e controlla cosa c'è. Hai sbagliato chiave nel tuo arrays. Controlla qual è la chiave corretta del tuo file di input.