We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

UploadBox not Uploading?

Thread ID:

Created:

Updated:

Platform:

Replies:

117129 Aug 19,2014 02:19 AM Aug 19,2014 08:10 AM ASP.NET MVC (Classic) 2
loading
Tags: UploadBox
lc
Asked On August 19, 2014 02:19 AM

Hi,
i'm trying to implement UploadBox as found in the documentation. however after selecting one or multiple files, nothing is happening... My uploadaction is not called. this is my code:

ConfigController

Function FileUpload() As ActionResult
        Dim myModel As New UploadBoxModel
        myModel.AutoUpload = True
        myModel.AllowMultipleFiles = True
        myModel.ExtensionsAllow = "txt"
        ViewData("upload") = myModel
        Return View()
    End Function

    <HttpPost> _
    Function SaveFile(upload As IEnumerable(Of HttpPostedFile)) As ActionResult
        For Each uFile In upload
            Dim fileName = Path.GetFileName(uFile.FileName)
            Dim destinationPath = Path.Combine(Server.MapPath("~/App_Data/Uploads"), fileName)
            uFile.SaveAs(destinationPath)
        Next
        Return Content("")
    End Function

    Function RemoveFile(fileNames As String()) As ActionResult
        For Each fullName In fileNames
            Dim fileName = Path.GetFileName(fullName)
            Dim physicalPath = Path.Combine(Server.MapPath("~/App_Data/Uploads"), fileName)
            If System.IO.File.Exists(physicalPath) Then
                System.IO.File.Delete(physicalPath)
            End If
        Next
        Return Content("")
    End Function

File Upload View (Razor)
<h2>FileUpload</h2>
@code
    Dim foo = Html.Syncfusion.UploadBox("upload").AsyncUpload(Function(a) a.SaveAction("SaveFile", "Config").RemoveAction("RemoveFile", "Config").AutoUpload(True)).CustomCSS("CustomCss-UploadBox").ShowFileDetails(True)
    foo.Render()
End Code


    <style type="text/css">
        #browse {
            margin: 30px 0 50px;
        }
    </style>

@code
    Dim styleManager = Html.Syncfusion.StyleManager
    styleManager.Register(Function(register) register.Add(ComponentType.UploadBox))
    styleManager.Minify = True
    styleManager.Render()
    
End Code

thanks for your help
kind regards 
lc

lc
Replied On August 19, 2014 02:24 AM

 myModel.ExtensionsAllow = "txt"
this line was just for testing purposes and did not change anythig

Jagan Prakash Vasu Devan [Syncfusion]
Replied On August 19, 2014 08:10 AM

Hi Ic,

 

We would like to let you know that the reported issue has occurs due to wrong extension type given in the controller page. It should be ‘.txt’ for text documents and save function will not be executed, in case of wrong extension type.

 

Function FileUpload() As ActionResult

            Dim myModel As New UploadBoxModel

            myModel.AutoUpload = True

            myModel.AllowMultipleFiles = True

            myModel.ExtensionsAllow = "txt"

            ViewData("upload") = myModel

            Return View()

        End Function

 

Please refer the attached sample for your reference.

 

Regards,

Jaganprakash


Attachment: UploadBox_3b08244d.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;