Init Local Uploader
======================

A lightweight, self-hosted PHP tool for uploading and processing images
directly on your own server. Designed for developers who prefer full
control over their data — no external storage, SDKs, or dependencies
required. Provides an instant HTML output with image dimensions and
lazy loading support.

----------------------------------------------------------------------
FEATURES
----------------------------------------------------------------------

- 100% self-hosted — files stay on your own server.
- Single or multiple image uploads.
- Optional folder organization under /uploads.
- Simple login authentication (username/password).
- File validation by extension and MIME type.
- Optional resizing by maximum width.
- Optional conversion to WebP with adjustable quality.
- Auto-create directories and handle duplicate filenames.
- Generates ready-to-use HTML output with:
  * width / height attributes
  * loading="lazy" (except first image)
  * auto ALT text (with incrementing index)
- LocalStorage integration to remember last-used settings.

----------------------------------------------------------------------
CONFIGURATION
----------------------------------------------------------------------

Edit the CONFIG section at the top of `init-local-uploader.php`:

define('USERNAME', 'admin');
define('PASSWORD', 'Admin@123');  // Supports both plain text and password_hash

Authentication notes:

- The PASSWORD value now supports two formats:
  1. Plain text
  2. A hashed string generated by PHP password_hash()
- The script automatically detects whether PASSWORD is a hashed value.
- If it is a valid password_hash, the login uses password_verify().
- If it is plain text, the login uses a secure comparison (hash_equals).

Example of using a hashed password:

  define('PASSWORD', '$2y$10$XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

To generate a password hash, run:

  echo password_hash('YourPassword', PASSWORD_DEFAULT);

System requirements:
- PHP >= 7.4 (PHP 8+ recommended)
- Extensions: gd, fileinfo
- Write permission for /uploads directory

----------------------------------------------------------------------
USAGE
----------------------------------------------------------------------

1. Place `init-local-uploader.php` on a PHP-enabled server.
2. Visit the script in your browser.
3. Log in using the configured username and password.
4. Select one or multiple images to upload.
5. Optionally set:
   - Custom upload folder (inside /uploads/)
   - Max image width for resizing
   - Compression quality (1–100)
   - WebP conversion
   - ALT text (used as base for generated image alt attributes)
6. Click “Upload & Generate HTML”.
7. Copy the generated HTML code and use it directly in your site.

Example ALT behavior:
- If you enter “Sunset” → output will be “Sunset - Image 1”, “Sunset - Image 2”…
- If left empty → output will be “Image 1”, “Image 2”…

----------------------------------------------------------------------
NOTES
----------------------------------------------------------------------

- The tool runs entirely on your own server — no remote APIs or keys.
- Ideal for self-hosted blogs, documentation, and portfolio sites.
- Supports JPG, PNG, GIF, and WebP input files.
- If WebP conversion is enabled, all output images will be saved as .webp.
- Use HTTPS to protect login credentials.
- Folder paths are automatically created if they don’t exist.

----------------------------------------------------------------------
CREDIT
----------------------------------------------------------------------

© Init HTML  
https://inithtml.com
