- Home
- Forum
- ASP.NET MVC (Classic)
- UploadBox not Uploading?
UploadBox not Uploading?
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
SIGN IN To post a reply.
2 Replies
LC
lc
August 19, 2014 06:24 AM UTC
myModel.ExtensionsAllow = "txt"
this line was just for testing purposes and did not change anythig
JP
Jagan Prakash Vasu Devan
Syncfusion Team
August 19, 2014 12:10 PM UTC
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
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
-
LC lc
- Aug 19, 2014 06:19 AM UTC
- Aug 19, 2014 12:10 PM UTC