I see that I can add custom fields, and following an example from the forums, I have added a "Title" and "Description" input fields to my upload form. But not sure what to do now. How to I get the values of the Title and Description fields into the arguments array of the StoreFile() method?
From my custom FileBrowserContentProvider:
| protected void RadFileExplorer2_ItemCommand(object sender, Telerik.Web.UI.RadFileExplorerEventArgs e) |
| { |
| if (e.Command == "UploadFile") |
| { |
| RadFileExplorer explorer = sender as RadFileExplorer; |
| RadUpload upload = explorer.Upload; |
| //e.Path holds the file path |
| string name = e.Path.Split(new char[] { '/' }).Last(); // get the filename including extension ; |
| foreach (UploadedFile uploadedFile in upload.UploadedFiles) |
| { |
| if (name.Equals(uploadedFile.GetName())) |
| { |
| string fileName = uploadedFile.GetName(); |
| string title = uploadedFile.GetFieldValue("Title"); |
| string description = uploadedFile.GetFieldValue("Desc"); |
| // ********** What do I do now? ***************// |
| break; |
| } |
| } |
| } |
| } |
From my custom FileBrowserContentProvider:
| public override string StoreFile(Telerik.Web.UI.UploadedFile file, string path, string name, params string[] arguments) |
| { |
| int fileLength = Convert.ToInt32(file.InputStream.Length); |
| byte[] content = new byte[fileLength]; |
| file.InputStream.Read(content, 0, fileLength); |
| string fullPath = CombinePath(path, name); |
| if (!Object.Equals(DataServer.GetItemRow(fullPath), null)) |
| { |
| DataServer.ReplaceItemContent(fullPath, content); |
| } |
| else |
| { |
| string title; string description; |
| try |
| { |
| title = arguments[0]; |
| description = arguments[1]; |
| } |
| catch (IndexOutOfRangeException) |
| { |
| DataServer.CreateItem(name, path, file.ContentType, false, fileLength, content); |
| return string.Empty; |
| } |
| DataServer.CreateItem(name, path, file.ContentType, false, fileLength, content, title, description); |
| } |
| return string.Empty; |
| } |
