# SFTP Auto-Upload Troubleshooting Guide

## ✅ Configuration Status
Your SFTP configuration has been updated with the following settings:
- **Host**: ftp.maham.usadomainhosting.com
- **Port**: 21
- **Protocol**: FTP
- **Remote Path**: /home/mahamusa/public_html
- **Upload on Save**: ✅ Enabled
- **Auto Upload**: ✅ Enabled

## 🔧 Steps to Fix Upload Issues

### Step 1: Reload VS Code/Cursor
1. Press `Ctrl+Shift+P`
2. Type "Reload Window"
3. Press Enter
4. Wait for VS Code to reload

### Step 2: Verify Extension is Installed
1. Press `Ctrl+Shift+X` to open Extensions
2. Search for "SFTP" by **Natizyskunk**
3. Make sure it's **installed and enabled**
4. If not installed, click "Install"

### Step 3: Test the Connection
1. Right-click on any file in your workspace
2. Select **"SFTP: Upload File"** (or "Upload Active File")
3. Check the **Output panel** (View → Output → Select "SFTP" from dropdown)
4. Look for success/error messages

### Step 4: Test Auto-Upload
1. Open any PHP file (e.g., `header.php`)
2. Make a small change (add a comment like `// test upload`)
3. Press `Ctrl+S` to save
4. Check the **status bar** (bottom of VS Code) - you should see upload progress
5. Check the **Output panel** for SFTP logs

### Step 5: Check Output Panel for Errors
1. Go to **View → Output** (or press `Ctrl+Shift+U`)
2. In the dropdown at the top right, select **"SFTP"**
3. Look for any error messages
4. Common errors:
   - **Connection timeout**: Check your internet/FTP server
   - **Authentication failed**: Verify username/password
   - **Path not found**: Check remotePath in sftp.json

## 🚨 Common Issues & Solutions

### Issue 1: Files Not Uploading on Save
**Solution:**
- Make sure `uploadOnSave: true` is in `sftp.json` ✅ (Already set)
- Check that `files.autoSave` is enabled in settings.json ✅ (Already set)
- Try manually uploading: Right-click file → "SFTP: Upload File"

### Issue 2: "Can't find config" Error
**This error appears when:**
- You try to browse remote files using SFTP Remote Explorer
- The extension tries to access remote files directly

**Solution:**
- **Ignore this error** - it doesn't affect upload-on-save functionality
- Don't use the "SFTP: List" or remote file browser features
- Focus on local file editing and auto-upload

### Issue 3: Upload Fails Silently
**Solution:**
1. Enable debug logging (already enabled in settings.json)
2. Check Output panel → SFTP
3. Verify FTP credentials are correct
4. Test connection manually:
   - Right-click file → "SFTP: Upload File"
   - Check for error messages

### Issue 4: Wrong Remote Path
**If files upload to wrong location:**
- Check `remotePath` in `.vscode/sftp.json`
- Should be: `/home/mahamusa/public_html`
- If your files are in a subfolder, adjust accordingly

## 📝 Manual Upload Commands

If auto-upload doesn't work, use these commands:

1. **Upload Single File:**
   - Right-click file → "SFTP: Upload File"
   - Or: `Ctrl+Shift+P` → "SFTP: Upload Active File"

2. **Upload Folder:**
   - Right-click folder → "SFTP: Upload Folder"

3. **Sync Folder:**
   - Right-click folder → "SFTP: Sync Local -> Remote"

## 🔍 Verify Upload Worked

1. **Check cPanel File Manager:**
   - Login to cPanel
   - Go to File Manager
   - Navigate to `public_html`
   - Check file modification time

2. **Check via FTP Client:**
   - Use FileZilla or WinSCP
   - Connect to your FTP server
   - Check file timestamps

## ⚙️ Current Configuration Files

### `.vscode/sftp.json`
- Contains FTP connection details
- Upload settings
- Ignore patterns

### `.vscode/settings.json`
- VS Code auto-save settings
- SFTP extension settings
- Debug logging enabled

## 🎯 Quick Test

1. Open `header.php`
2. Add this comment at the top: `<?php // SFTP TEST - <?php`
3. Save the file (`Ctrl+S`)
4. Wait 2-3 seconds
5. Check Output panel → SFTP for upload confirmation
6. Check cPanel File Manager to verify the change

## 📞 Still Not Working?

If uploads still don't work after these steps:

1. **Check Output Panel** for specific error messages
2. **Test FTP connection** manually with FileZilla
3. **Verify credentials** in cPanel FTP Accounts
4. **Check firewall/antivirus** isn't blocking FTP
5. **Try different protocol**: Change `"protocol": "ftp"` to `"protocol": "sftp"` (if SFTP is supported)

---

**Note:** The "Can't find config" error in the logs is related to remote file browsing, not upload-on-save. Your upload-on-save should work independently of this error.
