[Soci SLIP] upload di file con php

Lucio Crusca lucio a sulweb.org
Mar 22 Dic 2009 08:54:45 CET


In data martedė 22 dicembre 2009 01:59:25, Enrico Agliotti ha scritto:
> lo script č questo:
>
> $target_path = "uploads/";
> $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
>
> if ( move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)
> ) { echo "Il file ".basename( $_FILES['uploadedfile']['name'])." é
> stato caricato";
> } else
>         echo "errore";
>
> se il file č sopra i 100Kb il programma esegue l'else
> c'č modo di ricavare pių informazioni sulla natura dell'errore?

Puoi usare un error handler tuo e aggiungere qualche echo diagnostica 
(untested, ma dovrebbe funzionare, al massimo c'č qualche errore di sintassi):

function errHand($errno, $errstr, $error_file, $error_line, $error_context)
{
  echo "Errore $errno: $errstr <br />";
  echo "nel file $error_file alla linea $error_line <br />";
  echo "Dump delle variabili: <br />";
  print_r($error_context);

  die();
} 

set_error_handler("errHand"); 

$target_path = "uploads/";
$bname = basename( $_FILES['uploadedfile']['name']);
echo "per debug; bname = $bname <br />";
$target_path = $target_path . $bname;

if ( move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
 { echo "Il file ".basename( $_FILES['uploadedfile']['name'])." &eacute; stato 
caricato";
 } else
    echo "errore";




Maggiori informazioni sulla lista Soci