If I was you I'd look into the module
LWP::Simple. This should be more than capable of doing what you're trying to do.
You will need to specifically look into the built-in
is_error(); function which if true means that LWP::Simple was not able to retrieve your document or image. You can then call your sub to warn the user of his or her's error.
I wouldn't really recommend doing this in a busy forum environment, though, as it is likely to be a slightly slow process and I would also consider making this optional for the user, as I know I would prefer to double-check by hand (if I was unsure) than having to wait that exrta second every time I post a message. Just my opinion...
Hope this helps.
- wil