Now, i'm in project about portal using DotNetNuke.
This is my first time in DotNetNuke. I had watch your video about create module use razor, thats is so good for me, simple, direct to database without use DAL2, etc.
Now i'm done create razor module, create, update, delete from database.
But i'm still confuse how to upload file in razor module.
This is my script : (my reference from http://www.asp.net/web-pages/overview/data/working-with-files)
@using DotNetNuke.Common;
@using DotNetNuke.Entities.Users;
@using DotNetNuke.Web.UI.WebControls;
@using Microsoft.Web.Helpers;
@{
var db = Database.Open("SiteSqlServer");
var Alamat = Request.Form["iContent"];
var fileName = "";
if (IsPost) {
var fileSavePath = "";
var uploadedFile = Request.Files["uploadFile"];
fileName = Path.GetFileName(uploadedFile.FileName);
fileSavePath = Server.MapPath("~/App_Data/UploadedFiles/" + fileName);
uploadedFile.SaveAs(fileSavePath);
var insertQuery = "INSERT INTO TableName (Alamat, PathFIle) VALUES (@0, @1)";
db.Execute(insertQuery, Alamat, fileSavePath);
Response.Redirect(Url.NavigateToControl(""));
}
}
<!DOCTYPE html>
<html>
<head><title>FileUpload</title></head>
<body>
<form id="myForm" method="post" enctype="multipart/form-data" action="">
<div class="form-group">
<label class="col-lg-3 control-label">Alamat</label>
<div class="col-lg-9">
<input name="iAlamat" value="@Alamat" placeholder="Alamat" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Dokumen</label>
<div class="col-lg-9"><input name="uploadFile" id="uploadFile" type="file"></div>
</div>
<div class="line line-dashed"></div>
<div class="form-group">
<input id="cmdSave" type="submit" value="Kirim Pengaduan" class="btn btn-primary" />
<a href='@Url.NavigateToControl("")' id="cmdCancel" class="btn btn-danger">Batalkan</a>
</div>
</form>
</body>
</html>
i'm get blank page, when submit. whats wrong with that code?
what missing library. Please help me..
I need that solution, asap..