Proper Way To Upload Files
Last Post 02/21/2016 8:11 AM by Hani Khalaf. 3 Replies.
Author Messages Not Resolved
Hani Khalaf
Nuke Newbie
Nuke Newbie
Posts:2


--
02/18/2016 5:11 PM  
Hello,

I am Developing Some Modules For My Company, Basically Its Sort Of a Small CRM to Serve The Purpose

Anyway I am Uploading Files Manually Through RADAsyncUpload and Its Working But I Need To Do Everything Through DNN 's API As I'm Downloading and Doing Everything Else Through The API

I'm Facing Issues With Syncing Files and The Other Issue is That I Need The FileID and Other Attributes Immediately To Store Them in a Specific Table In The CRM's DB

So Can Someone Guide Me Or Provide Me a Snippet On How To Achieve This, I'm Writting Eveything In VB.Net Webforms and Building Everything On Top Of DNN 8

Thanks
Andy Stephenson DNN Creative
DNN Creative Staff
Nuke Master VI
Nuke Master VI
Posts:169


--
02/20/2016 4:55 AM  
Hi Hani,

I can't help you much here, but this might be useful to you:

http://www.dnnsoftware.com/forums/t...using-ajax

Andy
Hani Khalaf
Nuke Newbie
Nuke Newbie
Posts:2


--
02/21/2016 7:43 AM  
Hi Andy,

Thanks for your reply, i already saw that one, actually i was looking for something without a web service, just directly uploading

i will keep digging,

thanks again
Hani Khalaf
Nuke Newbie
Nuke Newbie
Posts:2


--
02/21/2016 8:11 AM  
Ok, It seems that its really simple, We will use an input control in our markup with type="file" and runat="server" tag then from code beind

we will use the FileManager Class and pass the stream of the input control to the FileManager.Instance.AddFile as follows:

The Code Of The Submit Button

 
 Private Sub btnUpload_Click(sender As Object, e As EventArgs) Handles btnUpload.Click
            Dim User As New UserInfo
            If Not IsNothing(Request.QueryString("UserID")) Then

                Dim UID As Integer = CInt(Request.QueryString("UserID"))
                User = UserController.Instance.GetUserById(PortalId, UID)

            Else
                User = UserController.Instance.GetCurrentUserInfo

            End If
            If (File1.PostedFile IsNot Nothing) AndAlso (File1.PostedFile.ContentLength > 0) Then
                Try
                    FileManager.Instance.AddFile(FolderManager.Instance.GetUserFolder(User), File1.PostedFile.FileName, File1.PostedFile.InputStream, True)
                    DotNetNuke.UI.Skins.Skin.AddModuleMessage(Me, "File Uploaded Successfully", DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.GreenSuccess)
                Catch ex As Exception
                    DotNetNuke.UI.Skins.Skin.AddModuleMessage(Me, "There Was An Error While Uploading The File - " & ex.Message, DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError)
                End Try
            Else
                DotNetNuke.UI.Skins.Skin.AddModuleMessage(Me, "Please Select a File To Upload.", DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.YellowWarning)
            End If
        End Sub
 


Hope It Helps


---