Intro

PHP code to upload files.

Configuration

Code

<!-- Role : Allow to Upload files
- Author : http://shebangthedolphins.net/
- Instructions  : 
- - Work with auth_basic_user_file
- 1.0 first version -->

<!doctype html>
<HTML>
<HEAD><TITLE>Upload Files</TITLE></HEAD>
<!-- <BODY bgcolor="#cccccc" text="#000000"> -->
<H2>Upload Files</H2>

<H4>Instructions</H4>
<ul>   
        <li>Size cannot exceed 2G</li>
        <li>No more than 40 files by send</li>
</ul>

<form method="post" enctype="multipart/form-data">
    <input type="file" name="my_file[]" multiple>
    <input type="submit" value="Upload">
</form>
        <?php  
                $user = $_SERVER['PHP_AUTH_USER'];
                if ($user == toto) {
                        $user = "toto";
                }
                $uploaddir = '/var/www/www.shebangthedolphins.net/' . $user . '/';
                if (isset($_FILES['my_file'])) {
                        $myFile = $_FILES['my_file'];
                        $fileCount = count($myFile["name"]);

                        for ($i = 0; $i < $fileCount; $i++) {
                                $uploadfile = $uploaddir . basename($myFile["name"][$i]);
        ?>
                <p>File #<?= $i+1 ?>:</p>
                <p>
                        Name: <?= $myFile["name"][$i] ?><br>
                        Size: <?= $myFile["size"][$i] ?><br>
                        Error: <?= $myFile["error"][$i] ?><br>
                </p>
        <?php  
                        if (move_uploaded_file($myFile["tmp_name"][$i], $uploadfile)) {
                                echo "Succes.\n";
                        } else {
                                echo "Failed!\n";
                        }
        }
        }
        ?>

<!-- DEBUG : -->
<!-- <p>user: <?= $uploaddir ?></p> -->
<!-- Temporary file: <?= $myFile["tmp_name"][$i] ?><br> -->
<!-- Type: <?= $myFile["type"][$i] ?><br> -->
<!--  Path: <?= $uploadfile ?><br> -->

        </BODY>
</HTML>


Licence Creative Commons
This websitehttp://shebangthedolphins.net is licensed to the public under a licence Creative Commons Attribution licence.
Contact :