# File Upload Portal

A secure file upload system for receiving files from clients with email and Telegram notifications.

## Files Created

- `receive.html` - Main upload interface with drag & drop
- `upload_handler.php` - Backend file processing
- `config_upload.php` - Configuration settings
- `uploads/` - Secure file storage directory
- `.htaccess` - Security rules for uploads directory

## Setup Instructions

### 1. Configure Settings

Edit `config_upload.php`:

```php
// Email Configuration
define('UPLOAD_RECIPIENT_EMAIL', 'your-email@example.com'); // Your email
define('UPLOAD_FROM_EMAIL', 'noreply@yourdomain.com'); // Your domain

// Telegram Configuration
define('TELEGRAM_BOT_TOKEN', 'YOUR_BOT_TOKEN'); // Get from @BotFather
define('TELEGRAM_CHAT_ID', 'YOUR_CHAT_ID'); // Your Telegram chat ID
```

### 2. Get Telegram Bot Token

1. Open Telegram and search for `@BotFather`
2. Send `/newbot` command
3. Follow instructions to create a bot
4. Copy the bot token
5. Add the token to `config_upload.php`

### 3. Get Telegram Chat ID

1. Start a chat with your bot
2. Send any message
3. Visit: `https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates`
4. Find your `chat_id` in the response
5. Add the chat ID to `config_upload.php`

### 4. Set Directory Permissions

Ensure the `uploads/` directory has write permissions:
```bash
chmod 755 uploads/
```

### 5. Test the Upload System

1. Visit: `https://yoursite.com/pages/upload/receive.html`
2. Upload test files
3. Check email and Telegram for notifications
4. Verify files are stored in `uploads/` directory

## Security Features

- **Token verification** using existing antibot system
- **File type validation** (only allowed formats)
- **File size limits** (100MB default)
- **Direct access prevention** via .htaccess
- **Script execution blocking** in uploads directory
- **Secure filename generation** (unique names)

## Usage

1. **Send link to client**: `https://yoursite.com/pages/upload/receive.html?ref=client@example.com`
2. **Client uploads files** after security verification
3. **You receive notifications** with file details
4. **Access uploaded files** in the `uploads/` directory

## Supported File Types

- **Documents**: PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX, TXT, CSV
- **Images**: JPG, PNG, GIF, WebP, SVG
- **Archives**: ZIP, RAR, 7Z, TAR, GZIP
- **Other**: JSON, XML

## Configuration Options

Edit `config_upload.php` to customize:

- `MAX_FILE_SIZE` - Maximum file size (default: 100MB)
- `MAX_FILES_PER_UPLOAD` - Maximum files per upload (default: 10)
- `FILE_RETENTION_DAYS` - Auto-cleanup old files (default: 7 days)
- `CLEANUP_OLD_FILES` - Enable automatic cleanup (default: true)

## Troubleshooting

### Upload Fails
- Check directory permissions for `uploads/`
- Verify PHP upload limits in `.htaccess`
- Check error logs for detailed messages

### No Email Notifications
- Verify SMTP settings on your server
- Check spam folder
- Verify recipient email address

### No Telegram Notifications
- Verify bot token is correct
- Verify chat ID is correct
- Ensure bot can send messages to your chat

### Files Not Accessible
- This is by design for security
- Files are stored securely in `uploads/`
- Access via server file system or download script

## Integration

The upload system uses the same:
- **Antibot verification** as your share portal
- **Token validation** system
- **Security twist** (real humans get "denied" token)

This ensures consistent security across all your file handling systems.
