SCIT APPROVED PACKAGE

SecureUploader

Enterprise‑grade file upload handler with MIME validation, size limits, image dimension checks, and atomic file operations.

Get Started Features

What is SecureUploader?

A PHP class that turns insecure file uploads into a reliable, secure, and developer‑friendly process.

Built with Object Oriented Programming (OOP) principles, SecureUploader validates files by their real MIME type (not just extension), enforces size limits, optionally checks image dimensions, and returns a clean UploadResult object. It follows all scit.zya.me contribution guidelines – includes at least one class, provides examples, and respects user tracking options.

Zero external dependencies
Works with any PHP 7.4+ project
Fully tested & documented
$uploader = new SecureUploader();
$uploader->allowMimeTypes(['image/jpeg', 'application/pdf'])
    ->setMaxSize(5 * 1024 * 1024)
    ->setMaxImageDimensions(1920, 1080);

$result = $uploader->upload($_FILES['document']);
if ($result->success) {
    echo "Uploaded to: " . $result->filePath;
} else {
    echo "Error: " . $result->errorMessage;
}

🔐 Key Features & Benefits

Real MIME Validation

Uses PHP's finfo to detect the actual file type – not the browser‑supplied $_FILES['type']. Blocks spoofed extensions (e.g., .jpg.exe).

Size & Dimension Limits

Enforce maximum file size (in bytes) and optional image width/height constraints – perfect for avatars, banners, or gallery uploads.

Atomic Write + Sanitization

Prevents file overwriting by appending a counter; sanitizes filenames to remove dangerous characters; uses temp + rename for safety.

Clean Result Object

Returns UploadResult with success, filePath, and errorMessage. No exceptions – easy to integrate.

Git / SVN / CVS Ready

Native support for daily imports from version control. The SCIT platform automatically pulls updates and notifies users.

Email Notifications

Once approved on scit.zya.me, tens of thousands of developers receive an email – guaranteed audience for your work.

📘 Step‑by‑Step Implementation Guide

1
Download the package from SCIT
Visit scit.zya.me, search for “SecureUploader”, and download the .zip or .tar.gz archive. (Registration may be required depending on the author’s tracking option – but examples/docs are always public.)
2
Include the class in your project
Copy classes/SecureUploader.php into your project (e.g., lib/). Then require it:
require_once 'lib/SecureUploader.php';
3
Instantiate & configure
Set allowed MIME types, max size, and upload directory:
$uploader = new SecureUploader();
$uploader->allowMimeTypes(['image/jpeg', 'image/png', 'application/pdf'])
    ->setMaxSize(10 * 1024 * 1024)
    ->setUploadDir('uploads/avatars/')
    ->setMaxImageDimensions(800, 600);
4
Process the uploaded file
In your form handler, call upload() and check the result:
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['myfile'])) {
    $result = $uploader->upload($_FILES['myfile']);
    if ($result->success) {
        echo "File saved to " . htmlspecialchars($result->filePath);
    } else {
        echo "Upload failed: " . $result->errorMessage;
    }
}
5
Test & deploy
Run a test upload – the class will create the upload directory automatically. For production, ensure the directory has write permissions (e.g., chmod 755). That’s it!
Pro Tips
  • Always store uploaded files outside the webroot if possible, or use a .htaccess to block script execution.
  • Combine SecureUploader with a CSRF token for maximum security.
  • Use setMaxImageDimensions() only for image types – it’s automatically ignored for PDFs.
  • The sanitizeFilename() method (default true) replaces unsafe characters with underscores.

Example Repository

The full source with examples (single upload, multi upload) is included in the SCIT download. You can also view the live demo in the examples/ folder.

🚀 Want to Contribute Your Own Package?

SCIT Contribution Rules (summary)
  • ✔️ Every package must contain at least one OOP class (no standalone scripts).
  • ✔️ Provide a short description (1 sentence) + detailed description (1 sentence per feature).
  • ✔️ Choose an Open Source license (BSD recommended – allows redistribution on SCIT conference CDs).
  • ✔️ Include separate examples and HTML documentation – they boost your ranking.
  • ✔️ Set tracking option: "Yes, except when viewing non‑class files" – lets users evaluate your examples/docs without login.
  • ✔️ No URLs or emails in descriptions – use the dedicated "Links" section.
Submission Workflow
  1. Register / log in at scit.zya.me.
  2. Click “Submit package” – fill name, base name, descriptions, license, group.
  3. Upload files manually or import from Git/SVN/CVS repository (recommended).
  4. Wait for approval (max 2 packages approved per day, usually < 5 days).
  5. Once approved, all registered users (tens of thousands) receive an email notification.
  6. You will see download statistics and can release updates – users who downloaded before get notified again.
Understanding Tracking Options (for authors)

The SCIT platform offers three user tracking settings. For SecureUploader, the author chose Option 1 – "Yes, except when viewing non-class files".

OptionWhat users see without loginEffect on rankings / update notifications
0 – No trackingAll files (classes, examples, docs)No download tracking, no update emails, not counted in top downloads
1 – Non‑class files publicExamples, docs, other files. Classes require loginLogged‑in users are tracked (rankings + update emails). Anonymous users see most of the content.
2 – Full trackingLogin required for any file view/downloadMaximises tracking accuracy but may reduce initial interest.

SecureUploader’s choice (Option 1) is the recommended compromise: new users can immediately see the examples and documentation, then decide to register for the class files.

Ready to secure your file uploads?

Download SecureUploader now from scit.zya.me and join a community of thousands of developers.

Download .ZIP View on Git

Package approved under BSD 3‑Clause license • Compatible with PHP 8.1+ • Includes full examples & docs