Merhaba;
Sorunu çözdüm arkadaşlar. (Yine kendim çözdüm ) preg_match ile uğraşmaya gerek yokmuş. Bu işi yapan bir function varmış.

<?php

$filepath = 'http://www.test.com/files/332/file.zip' 

$path = pathinfo( $filepath );
echo $path['dirname']; // çıktı: http://www.test.com/files/332/

?>