Absolutely, and it works well. I use samba shares all the time. My suggestion would be to get your connection working first and then apply it to your $dir variable with PHP. What I mean is, try some command line work first. Are you able to run a simple listing command from the bash prompt?
ls -la /home/public
If not, you don't have your network share working. Once you get that working you simply use the same path in your $dir variable.