Photonic realization of erasure-based nonlocal measurements