SoFunction
Updated on 2025-03-09

Full version of multi-file upload system

<?php
//The full version of the multi-file upload system
// Powerful function, can control the number of uploaded files at will, whether to overwrite it

include("../include/");
$title = "uploader for multiple files";
include("../include/");

//Define the number of files allowed to be uploaded

define("UPLOAD_NO", 10);

echo("<p align='center'><font size='4' color='#000080'> Welcome! <br> Upload at most at a time".UPLOAD_NO." Files <br> <HR>n");
if($REQUEST_METHOD!="POST"){
    echo("<form enctype="multipart/form-data" method=post>n");
    echo("<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="3000000">n");

    for($i=1;$i<=UPLOAD_NO;$i++){
        echo("<input type=file name=infile$i>   ");

        if($i%2==0)
        echo("<br>n");
    }

echo("<br><br><input type="checkbox" name="overload" value="ON"></font> <font color='#ff0000'> Does it overwrite existing files? </font>");
echo("<br><br><input type=submit value=upload></form>n");
}
else{
//Processing upload
    $noinput = true;
    for($i=1;$noinput&&($i<=UPLOAD_NO);$i++){
         if(${"infile".$i}!="none") $noinput = false;
    }
    if($noinput){
echo("<font size='4' color='#000080'>No selected file, return to try again </font>");
        exit();
    }
echo("<p align='center'><font size='4' color='#000080'> The file you selected has been successfully uploaded to the server's temporary directory! </font><br>");
    echo("<table border='1' width='84%' height='52' bordercolorlight='#008080' bordercolordark='#008080'>
        <tr>
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / �
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / �
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / �
        </tr>");

    for($i=1;$i<=UPLOAD_NO;$i++){
        $just=${"infile".$i."_size"};
        $fp_size[i] = $just;

        if($overload!=ON){
            if(file_exists(AddSlashes(dirname($PATH_TRANSLATED))."\upload\".${"infile".$i."_name"}))
echo "<font size='4' color='#ff0000'> The file you uploaded is <font color='#000000'>".${"infile".$i."_name"}."</font> already exists, and the copy of the file failed!</font><br>";
            else{
                if(${"infile".$i}!="none"&&copy;(${"infile".$i},AddSlashes(dirname($PATH_TRANSLATED))."/upload/".${"infile".$i."_name"})&&unlink(${"infile".$i})){
                $str = ${"infile".$i."_name"};
                echo("<tr>
                    <td width='14%' height='19'>$i</td>
                    <td width='52%' height='19'>$str</td>
                    <td width='34%' height='19'>$fp_size[i]</td>
                    </tr>");
                  }
            }
        }
        else{
            if(${"infile".$i}!="none"&&copy;(${"infile".$i},AddSlashes(dirname($PATH_TRANSLATED))."upload".${"infile".$i."_name"})&&unlink(${"infile".$i})){
                $str = ${"infile".$i."_name"};
                echo("<tr>
                    <td width='14%' height='19'>$i</td>
                    <td width='52%' height='19'>$str</td>
                    <td width='34%' height='19'>$fp_size[i]</td>
                    </tr>");
            }
        }

    }
    echo "</table>";             
}

include("../include/");

?>