/// <summary> /// Upload a file to the server. The intent is that a user will click a submit button /// on the Due Diligence page. This will bring up a list of all the documents they have /// selected for upload for them to review. If they want to upload that list then they /// click another button. That button will call this function. /// </summary> /// <param name="pathName">Current location of the file you wish to upload</param> /// <param name="fs">File stream in which the file is located for uploading. example: FileUpload1.PostedFiles.InputStream</param> /// <param name="dbObject">Used to access the database</param> /// <param name="sesBucket">Current DataBucket that is in the Session variable</param> public Label UploadFile(CruxDB dbObject, DataBucket sesBucket, HttpRequest Request, HttpContext Context, int docClassId) { Label lblFileUploadStatus = new Label(); HttpFileCollection multipleFiles = Request.Files; for (int fileCount = 0; fileCount < multipleFiles.Count; fileCount++) { string fileName = Path.GetFileName(multipleFiles[fileCount].FileName); string ext = Path.GetExtension(fileName); HttpPostedFile uploadedFile = multipleFiles[fileCount]; if (uploadedFile.ContentLength > 0) { Stream fs = uploadedFile.InputStream; BinaryReader br = new BinaryReader(fs); Byte[] bytes = br.ReadBytes((Int32)fs.Length); dbObject.insertProjectDocument(sesBucket._userID, fileName, bytes, docClassId); lblFileUploadStatus.Text += fileName + "Saved <BR>"; } } return lblFileUploadStatus; }