Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Enabling Uploaded Files 

To enable file upload

  1. Read the information in Handling Uploaded Files and decide whether you really need to allow file upload. Understand the responsibilities in terms of the code you write and the long-term management of the site.

  2. Limit the size of valid requests to a sensible value. See Limiting the Size of a Request for instructions.

  3. Override CRequestHandlerT::FormFlags in your request handler to allow uploaded files. Include the ATL_FORM_FLAG_IGNORE_EMPTY_FILES flag, if possible, to avoid writing empty files to disk.

  4. Use CHttpRequest::m_Files or CHttpRequest::GetFormVars to access the uploaded files from CRequestHandlerT::m_HttpRequest. The m_Files collection contains only the uploaded files and provides complete information about each of them. GetFormVars contains standard form fields along with the field names and temporary file names of the uploaded files.

  5. Be sure to delete any files that you do not need or were not expecting. ATL Server will delete any files that you do not remove from the CHttpRequest::m_Files collection when the request is finished. To prevent files being deleted, remove them from the CHttpRequest::m_Files collection, for example by calling RemoveKey.

See Also

Community Additions

© 2015 Microsoft