I’m building a portal that will allow users to upload files. I need to make sure that these files do not contain viruses. My ideal solution would be to have the host OS AV keep a watch on temporary folders and scan any incoming files.
When a file is uploaded in ASP.Net 2, does it get written to disk in a temp folder, or is it persisted in memory? If it is written to disk, will IIS lock it so that the AV cannot remove it? And if it is written to disk, where?
I think the ideal way would be have an ‘Incoming’ folder that has been given the necessary permissions for ASP.NET to save files. I have never encountered a situation where files remain locked even after you call
SaveAson the FileUpload control.Note that the FileUpload control does not upload the file until you call
SaveAsand this is when the file is persisted to disk on the server. It seems to hold all file contents in anHttpInputStream, which is written to disk when theSaveAsmethod is called.The file(s) should then be free to be scanned by your AV application. In case an error occurs, you can give relevant feedback to the user.