How to validate a file upload field added to a form using hook_form_alter?
What you describe is what the Upload module does: In upload_form_alter() (an implementation of hook_form_alter()), it adds the form element to the node edit forms, and in the form submission handler it adds to the form (upload_node_form_submit()), it handles the uploaded files. With _upload_file_limits(), it checks the user didn't reach the assigned quota; with file_save_upload(), it checks the file passes the validators, and saves the file.

The Upload module, once enabled, allows you to enable the file upload for the content types. For example, for the Page content type, you can enable it at admin/content/node-type/page.



In the node edit form, the form element the Upload module adds appears as in the following screenshot.



If the Upload module is already enabled, and you need a upload form element more, than you should use the CCK module.