I'm messing with the fileupload control. I'm normally a big advocate for the "store it in the filesystem and keep a link in the database", but I was working on a "quick and dirty" and was going to just store it in the DB.
So, the upload works fine and binary data is in the database, but how can I capture the filename to store as well to display to the user later without them having to type it into a text box (they entered the upload filename, I'm sure there is some place I can override and use that to insert as the filename?).
Also, since I'm a SQL Server guy, is there support for 2008s filestream objects?
Thanks
The folder where the files reside is specified in the appSettings section in Web.config. The setting is named SDBF_UploadDirectory and must point to a virtual directory. For example "~/UploadDir/". See the installed DemoSite Web Project.
In ReadOnly mode the FileNameFromDiskTemplate template displays either a link to download the file or an image depending on the extension of the actual file. In Edit mode the user can upload a new file. The file is saved in the designated folder and only the file name is stored in the database. If the database column has text length limitation then the file name is shortened( preserving the extension ) in order to fit into the specified limit.
You can set a maximum permitted size of the uploaded files for the ImageFromDBTemplate, FileFromDBTemplate and FileNameFromDiskTemplate templates in two ways:
The value of SDBF_UploadMaxFileBytes and MaximumValue properties should be in bytes. For example to set maximum 4 MB you should put 4194304 as value. 4 MB = 4*1024*1024 = 4194304. If nothing is specified, then by default the maximum permitted upload file size is 100 K.
// The new file was uploaded. Send its filename to the hosting page. this.SendCustomEventToContainer(btnUpload, new ValidateCustomEvent(fileUpload.FileName));
protected void ctrlThumbNailPhoto_CustomEvent(BaseSmartDBControl sender, BaseSmartDBControlCustomEventArgs args) { // Get the file name that was send by the upload template. ValidateCustomEvent ev = args.Event as ValidateCustomEvent; if (ev == null) return; string fileName = ev.Value as string; // Find the textbox for editing the ThumbnailPhotoFileName db column and set its text to the just uploaded filename. TextBox TextBoxValueString = ctrlThumbnailPhotoFileName.FindControl("TextBoxValueString") as TextBox; if (TextBoxValueString != null) TextBoxValueString.Text = fileName; }