View Single Post
  #3 (permalink)  
Old May 10th, 2005, 11:31 AM
cli cli is offline
Authorized User
 
Join Date: May 2005
Location: , , .
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok i'm studing your script only a thing thah i don't understand the form for upload i've resolve your scritp this way but doesn't work::(


Code:
<?
function upload_form() {
   //global $PHP_SELF;
?>
<form method="POST" enctype="multipart/form-data" 
   action="<? echo $PHP_SELF ?>">
   <input type="hidden" name="action" value="upload">
   Upload file!
   <input type="file" name="userfile">
   <input type="file" name="userfile">
   <input type="file" name="userfile">
   <input type="submit" name="submit" value="upload">
</form>
<?
}

function upload_file() {

        for($i=0; $i<3; $i++) {
            if($_FILES['userfile']['size'][$i]>"1048576")
                echo "<pre>Can't upload a file; filesize > 1 mb or 1024 kb or 1048576 bytes.</pre>";
            if ( ($_FILES['userfile']['size'][$i]<="1048576") && ($_FILES['userfile']['tmp_name'][$i]!="") ) {
                if (move_uploaded_file($_FILES['userfile']['tmp_name'][$i], $_SERVER['DOCUMENT_ROOT']."/documenti_master/".$_FILES['userfile']['name'][$i])) {
                    echo "<pre>Upload successful.\n";
                    echo "File: ".$_FILES['userfile']['name'][$i]." (".$_FILES['userfile']['size'][$i].") bytes\n";
                    echo "Renamed: ".$_FILES['userfile']['name'][$i]."</pre>\n";
                }
                else
                error_reporting(E_ALL);
                    echo "<pre>Can't upload file due an error.</pre>";
            }        
            if( ($_FILES['userfile']['tmp_name'][$i]=="") && ($_FILES['userfile']['size'][$i]=="0") )
                echo "<pre>No file specified.</pre>";
        }

}
?>
<html>
<head><title>file upload</title></head>
<body>
<?
if($action == 'upload') upload_file();

else upload_form();
?>
</body>
</html>
The script say: "Can't upload file due an error"

Reply With Quote