A secure, privacy-focused, and user-friendly HTML file hosting platform built with PHP
Features β’ Installation β’ Usage β’ Security β’ License
xsukax HTML File Hosting is a lightweight, single-file PHP application that provides instant HTML file hosting with full CSS and JavaScript support. Designed with security and privacy as core principles, this platform enables users to upload, share, and host HTML files without requiring registration or authentication.
The application validates all uploaded content, generates unique shareable URLs, and serves files with appropriate security headers to prevent malicious code execution while preserving the original functionality and design of hosted HTML pages.
- Instant HTML Hosting: Upload HTML files and receive shareable links immediately
- Zero Barrier Entry: No registration, authentication, or login required
- Full Resource Support: External CSS, JavaScript, fonts, and images work seamlessly
- Privacy-First Architecture: No user tracking, data collection, or personal information storage
- Security-Hardened: Multiple validation layers prevent malicious code execution
xsukax HTML File Hosting implements a comprehensive security architecture that protects both the server infrastructure and end users from potential threats while respecting user privacy.
graph TD
A[File Upload] --> B{File Size Check}
B -->|> 5MB| C[Reject: Too Large]
B -->|β€ 5MB| D{Extension Check}
D -->|Not .html/.htm| E[Reject: Invalid Type]
D -->|Valid Extension| F{MIME Type Validation}
F -->|Invalid MIME| G[Reject: Not HTML]
F -->|Valid MIME| H{Content Analysis}
H -->|PHP/ASP Tags| I[Reject: Server Code]
H -->|Malicious Patterns| J[Reject: Dangerous Content]
H -->|Valid HTML| K[Accept & Store]
K --> L[Generate Unique ID]
L --> M[Return Shareable URL]
style C fill:#ff6b6b
style E fill:#ff6b6b
style G fill:#ff6b6b
style I fill:#ff6b6b
style J fill:#ff6b6b
style K fill:#51cf66
style M fill:#51cf66
| Security Feature | Implementation | Protection Against |
|---|---|---|
| MIME Type Validation | Uses PHP's finfo_open() to verify actual file content beyond extensions |
File type spoofing, malicious uploads |
| Content Sanitization | Scans for PHP tags (<?php), ASP tags (<%), and dangerous patterns |
Server-side code injection, remote code execution |
| Unique File Identifiers | 16-byte cryptographically secure random IDs via random_bytes() |
File enumeration, unauthorized access |
| Security Headers | X-Frame-Options, X-Content-Type-Options, X-XSS-Protection, CSP |
Clickjacking, MIME sniffing, XSS attacks |
| Directory Protection | .htaccess rules block direct access to upload directory |
Directory traversal, unauthorized file access |
| File Permissions | Strict 0644 permissions on uploaded files |
Unauthorized modification, execution |
| Content Security Policy | Balanced CSP allows external resources while restricting inline execution | XSS, code injection, unauthorized resource loading |
- No User Tracking: Zero analytics, cookies, or tracking mechanisms
- No Data Collection: No personal information, IP addresses, or metadata stored
- No Authentication Required: Complete anonymity for all users
- No Session Storage: Files are not associated with user identities
- Transparent Operation: Open-source code allows full security audit
The application creates a secured upload directory with multiple protection layers:
uploads/
βββ .htaccess # Blocks direct HTTP access
βββ index.php # Returns 403 Forbidden on directory access
βββ [uploaded files] # Accessible only via application logic
- π Instant Upload: Drag-and-drop or click-to-browse file upload interface
- π Unique URLs: Cryptographically secure 16-character file identifiers
- π¨ Full Formatting: Preserves all CSS styling, JavaScript functionality, and external resources
- π± Responsive Design: Mobile-friendly interface built with Tailwind CSS
- ποΈ File Management: Users can delete their uploaded files via confirmation dialog
- π Live Statistics: Real-time display of total hosted files and storage usage
- β‘ Zero Configuration: Single-file deployment with automatic directory initialization
| Feature | xsukax | Pastebin-style Services | GitHub Pages | Traditional Hosting |
|---|---|---|---|---|
| No Registration | β | β Requires account | β Requires account | |
| Instant Deployment | β | β | ||
| External Resources | β Full support | β | β | |
| Privacy-First | β No tracking | β Analytics | ||
| File Management | β Delete anytime | β | β | |
| Self-Hosted | β | β | β | β |
| Cost | π Free | π/π° Freemium | π Free | π° Paid |
- Visual Feedback: Real-time file information display before upload
- Copy-to-Clipboard: One-click URL copying with success notification
- Error Handling: Clear, descriptive error messages with actionable guidance
- Loading States: Visual indicators during upload process
- Confirmation Dialogs: Prevents accidental file deletion
- Smooth Animations: Professional fade-in and scale effects
- PHP: Version 7.4 or higher (8.0+ recommended)
- PHP Extensions:
fileinfo(for MIME type detection)mbstring(for string handling)
- Web Server: Apache, Nginx, or compatible server
- File Permissions: Write access for upload directory creation
- Storage: Minimum 100MB recommended for initial deployment
Clone the repository or download the latest release:
# Clone via Git
git clone https://github.com/xsukax/xsukax-HTML-File-Hosting.git
cd xsukax-HTML-File-Hosting
# Or download directly
wget https://github.com/xsukax/xsukax-HTML-File-Hosting/archive/refs/heads/main.zip
unzip main.zip
cd xsukax-HTML-File-Hosting-mainFor Apache:
# Copy to web root
sudo cp index.php /var/www/html/
# Or create a dedicated directory
sudo mkdir /var/www/html/htmlhost
sudo cp index.php /var/www/html/htmlhost/
# Set proper permissions
sudo chown www-data:www-data /var/www/html/htmlhost
sudo chmod 755 /var/www/html/htmlhostFor Nginx:
# Copy to web root
sudo cp index.php /usr/share/nginx/html/
# Set proper permissions
sudo chown nginx:nginx /usr/share/nginx/html/index.php
sudo chmod 644 /usr/share/nginx/html/index.phpAdjust PHP settings for optimal performance:
# In php.ini or .user.ini
upload_max_filesize = 5M
post_max_size = 6M
max_execution_time = 30
memory_limit = 128M
file_uploads = OnAccess the application in your browser:
http://your-domain.com/index.php
You should see the upload interface immediately. The uploads/ directory will be created automatically on first access.
Enable HTTPS:
# Install Certbot for Let's Encrypt
sudo apt install certbot python3-certbot-apache # For Apache
sudo apt install certbot python3-certbot-nginx # For Nginx
# Obtain certificate
sudo certbot --apache -d your-domain.com # For Apache
sudo certbot --nginx -d your-domain.com # For NginxConfigure Firewall:
# Allow HTTP and HTTPS only
sudo ufw allow 'Apache Full' # For Apache
sudo ufw allow 'Nginx Full' # For Nginx
sudo ufw enableflowchart LR
A[User Browser] -->|Upload HTML| B[index.php]
B -->|Validate| C{Security Checks}
C -->|Pass| D[Store in uploads/]
C -->|Fail| E[Show Error Modal]
D -->|Generate ID| F[Return URL]
F -->|Copy & Share| G[Recipients]
G -->|Access URL| H[index.php?x=ID]
H -->|Serve File| I[View HTML]
style C fill:#4dabf7
style D fill:#51cf66
style E fill:#ff6b6b
style F fill:#51cf66
style I fill:#51cf66
Method A: Drag and Drop
- Open the application in your browser
- Drag your HTML file into the upload zone
- The file information will display automatically
- Click the "Upload" button
Method B: File Browser
- Click the "Choose File" button
- Select your HTML file from the file picker
- Review the file details
- Click the "Upload" button
After successful upload, you'll receive:
- Shareable URL:
https://your-domain.com/index.php?x=abc123def456 - File Details: Original filename, file size, unique identifier
- Action Buttons: View the file or delete it
Copy the URL:
- Click the "Copy" button next to the URL field
- A success notification confirms the copy action
- Share the URL via email, messaging, or social media
Recipients can access the file by:
- Opening the shared URL in any browser
- The HTML file renders with all CSS and JavaScript intact
- External resources (CDN libraries, fonts, images) load normally
To remove a hosted file:
- Use the URL provided after upload
- Click the "Delete File" button
- Confirm deletion in the modal dialog
- The file is permanently removed
sequenceDiagram
participant U as User
participant A as Application
participant V as Validator
participant S as Storage
participant R as Recipient
U->>A: Upload HTML file
A->>V: Validate content
V->>V: Check size, type, MIME
V->>V: Scan for malicious code
alt Validation Fails
V->>A: Return error
A->>U: Show error modal
else Validation Passes
V->>S: Store file
S->>A: Return file ID
A->>U: Display shareable URL
U->>R: Share URL
R->>A: Request file (URL with ID)
A->>S: Retrieve file
S->>A: Return HTML content
A->>R: Serve with security headers
end
The header displays real-time statistics:
- Files Hosted: Total number of HTML files stored
- Storage Used: Aggregate size of all uploaded files
Edit the configuration constants in index.php:
// Modify these values as needed
define('MAX_FILE_SIZE', 10 * 1024 * 1024); // Change to 10MB
define('ALLOWED_EXTENSIONS', ['html', 'htm', 'xhtml']); // Add .xhtmlCreate a cleanup script to remove old files:
#!/bin/bash
# cleanup.sh - Remove files older than 30 days
find /var/www/html/htmlhost/uploads -name "*.html" -mtime +30 -deleteAdd to crontab:
# Run daily at 2 AM
0 2 * * * /path/to/cleanup.shWhile the application works out-of-the-box, you can customize behavior by editing constants:
// Maximum file size (bytes)
define('MAX_FILE_SIZE', 5 * 1024 * 1024);
// Allowed file extensions
define('ALLOWED_EXTENSIONS', ['html', 'htm']);
// Allowed MIME types for validation
define('ALLOWED_MIME_TYPES', ['text/html', 'text/plain', 'application/octet-stream']);
// Upload directory name
define('UPLOAD_DIR', 'uploads');Apache (.htaccess in application directory):
# Prevent PHP execution in uploads directory
<Directory "uploads">
php_flag engine off
Options -Indexes
Order deny,allow
Deny from all
</Directory>
# Enable mod_rewrite for clean URLs (optional)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-f0-9]{16})$ index.php?x=$1 [L,QSA]Nginx (add to server block):
# Block access to uploads directory
location /uploads/ {
deny all;
return 403;
}
# Optional: Clean URLs
location ~ ^/([a-f0-9]{16})$ {
try_files $uri /index.php?x=$1;
}| Issue | Cause | Solution |
|---|---|---|
| Upload fails silently | PHP upload_max_filesize too low |
Increase in php.ini to at least 5M |
| Permission denied error | Web server cannot create uploads/ |
Run chmod 755 on application directory |
| File not found (404) | Incorrect URL or file deleted | Verify URL contains correct 16-character ID |
| MIME validation fails | fileinfo extension disabled |
Enable in php.ini: extension=fileinfo |
| Cannot delete files | File permissions too restrictive | Ensure files have 644 permissions |
Enable error display for troubleshooting:
// Temporarily add at top of index.php
error_reporting(E_ALL);
ini_set('display_errors', 1);Remember to disable before production use.
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PSR-12 coding standards for PHP
- Maintain existing security validation patterns
- Add comments for complex logic
- Test thoroughly before submitting
This project is licensed under the GNU General Public License v3.0.
- Repository: https://github.com/xsukax/xsukax-HTML-File-Hosting
- Issues: Report a bug or request a feature
- License: GNU GPL v3.0
For questions, issues, or suggestions:
- Open an issue on GitHub
- Check existing issues for solutions
- Review the troubleshooting section above
Made with β€οΈ by the xsukax
β Star this repository if you find it useful!