# Storage Link Fix for Server Deployment

## Problem
Images are not visible on the server even though they work locally. This is because the symbolic link from `public/storage` to `storage/app/public` is missing on the server.

## Solution

### Method 1: Using the PHP Script (Easiest)

1. Upload the `create-storage-link.php` file to your server's `public` directory
2. Access it via browser: `https://shivajewellers.in/create-storage-link.php`
3. The script will automatically create the storage link
4. **IMPORTANT:** Delete the `create-storage-link.php` file after successful execution for security

### Method 2: Using SSH/Command Line (Recommended for Production)

If you have SSH access to your server, run:

```bash
cd /path/to/your/project
php artisan storage:link
```

Or manually create the symlink:

```bash
ln -s /path/to/your/project/storage/app/public /path/to/your/project/public/storage
```

### Method 3: Using cPanel File Manager

1. Log into cPanel
2. Navigate to File Manager
3. Go to the `public` directory
4. If `storage` folder exists, delete or rename it
5. Create a symbolic link:
   - Some cPanel versions have a "Create Symbolic Link" option
   - Or use the terminal in cPanel to run: `ln -s ../storage/app/public storage`

### Method 4: Manual Copy (Not Recommended - Last Resort)

If symlinks are not supported on your server:

1. Copy all files from `storage/app/public` to `public/storage`
2. Note: You'll need to keep both directories in sync when new images are uploaded
3. Consider using a deployment script to automate this

## Verification

After creating the link, verify it works:

1. Check if the link exists: `https://shivajewellers.in/storage/categories/`
2. Test a specific image: `https://shivajewellers.in/storage/categories/v0pViHxtDzL3SKI44hLNTlAdHkEf2OpdZjJogV1m.jpg`
3. If images load, the fix is successful!

## Troubleshooting

### Issue: "Permission denied" error
- Solution: Check file permissions on `storage/app/public` directory (should be 755)
- Ensure the web server user has read access

### Issue: Symlink created but images still not loading
- Check `.htaccess` file in `public` directory allows symlinks
- Verify `Options +FollowSymLinks` is enabled
- Check web server configuration allows symlinks

### Issue: "Link already exists" error
- The link might point to wrong location
- Delete the existing link and recreate it
- Use: `rm public/storage` (if it's a symlink) or delete the directory

### Issue: Images work locally but not on server
- Local (Windows): Uses junctions which work differently
- Server (Linux): Needs proper symlink
- Solution: Always run `php artisan storage:link` on the server

## File Structure

After successful setup, your structure should be:

```
project/
├── public/
│   ├── storage -> ../storage/app/public (symlink)
│   └── index.php
└── storage/
    └── app/
        └── public/
            ├── categories/
            ├── products/
            └── banners/
```

## Security Note

**Always delete `create-storage-link.php` after use!** This file should never remain on a production server.

