with folder
function UploadImages($weburl)
{
$docLibraryName = "TestLibrary"
$localFolderPath = "c:\Install\Docs"
$subFolderName="SubFolder" ##Pass your Folder Name Here
Add-PsSnapin Microsoft.SharePoint.PowerShell -erroraction silentlycontinue
$web = Get-SPWeb -Identity $webUrl
$docLibrary = $web.Lists[$docLibraryName]
#Attach to local folder and enumerate through all files
$files = ([System.IO.DirectoryInfo] (Get-Item $localFolderPath)).GetFiles() | ForEach-Object {
#Create file stream object from file
$fileStream = ([System.IO.FileInfo] (Get-Item $_.FullName)).OpenRead()
$contents = new-object byte[] $fileStream.Length
$fileStream.Read($contents, 0, [int]$fileStream.Length);
$fileStream.Close();
write-host "Copying" $_.Name "to" $docLibrary.Title "in" $web.Title "..."
#Add file
$folder = $web.getfolder($docLibrary.Title+"/"+$subFolderName) ##Changed code here to get subfolder
$spFile = $folder.Files.Add($folder.Url + "/" + $_.Name, $contents, $true)
$spItem = $spFile.Item
Write-Host -f Green "Added Images to library !!!"
}
}
Example with C# click here