]> git.mxchange.org Git - simple-upload.git/commitdiff
Added maximum upload size display
authors-ko <aleks@s-ko.net>
Sat, 27 Sep 2014 19:43:22 +0000 (20:43 +0100)
committers-ko <aleks@s-ko.net>
Sat, 27 Sep 2014 19:43:35 +0000 (20:43 +0100)
index.php

index 513d7d14fc567a6b6f83c1c20db660d8d46a2be3..715b4ffa8133434f7a983347b1f5515fd4408f2e 100644 (file)
--- a/index.php
+++ b/index.php
@@ -52,7 +52,7 @@
 
 
                // Display debugging information
-               debug => false
+               debug => $_SERVER['SERVER_NAME'] === 'localhost'
 
        );
 
        // URL to upload page
        $data['pageurl'] = "http" . (($_SERVER['SERVER_PORT']==443) ? "s://" : "://") . $_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']) . '/';
 
+       // Use canonized path
+       $data['uploaddir'] = realpath($settings['uploaddir']);
+
+       // Maximum upload size, set by system
+       $data['max_upload_size'] = ini_get('upload_max_filesize');
+
        if ($settings['debug']) {
         // Enabling error reporting
         error_reporting(E_ALL);
                        if ($settings['random_name_keep_type'])
                                $data['target_file_name'] .= '.' . pathinfo($data['uploaded_file_name'], PATHINFO_EXTENSION);
         }
-               $data['upload_target_file'] = $settings['uploaddir'] . DIRECTORY_SEPARATOR . $data['target_file_name'];
+               $data['upload_target_file'] = $data['uploaddir'] . DIRECTORY_SEPARATOR . $data['target_file_name'];
                $data['tmp_name'] = $_FILES['file']['tmp_name'];
 
        if ($settings['debug']) {
                </style>
        </head>
        <body>
+               <h1>Simple PHP Upload</h1>
+               <p>
+                       Maximum upload size: <?php echo $data['max_upload_size']; ?>
+               </p>
                <form action="<?= $data['scriptname'] ?>" method="POST" enctype="multipart/form-data" class="dropzone" id="my-awesome-dropzone">
                        <div class="fallback">
                                Choose File: <input type="file" name="file" /><br />