Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
142 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
using System.Web.Mvc; | ||
using System.IO; | ||
|
||
|
||
|
||
namespace JoMAR.Controllers | ||
{ | ||
public class UploadController : Controller | ||
{ | ||
// | ||
// GET: /Upload/ | ||
|
||
public ActionResult Index() | ||
{ | ||
return View(); | ||
} | ||
|
||
[HttpPost] | ||
public ActionResult Index(HttpPostedFileBase file) | ||
{ | ||
|
||
// Verify that the user selected a file | ||
if (file != null && file.ContentLength > 0) | ||
{ | ||
// extract only the fielname | ||
var fileName = Path.GetFileName(file.FileName); | ||
// store the file inside ~/App_Data/uploads folder | ||
var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName); | ||
file.SaveAs(path); | ||
} | ||
// redirect back to the index action to show the form once again | ||
return RedirectToAction("Index"); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
@model JoMAR.Models.ChatModel | ||
|
||
@{ | ||
ViewBag.Title = "UploadFile"; | ||
Layout = "~/Views/Shared/_Layout.cshtml"; | ||
} | ||
|
||
|
||
<h2>UploadFile</h2> | ||
|
||
|
||
<h2>Chatroom: @Html.DisplayTextFor(model => model.Name)</h2> | ||
|
||
|
||
|
||
@using (Html.BeginForm("Index", "Upload", FormMethod.Post, new { enctype = "multipart/form-data" })) | ||
{ | ||
@Html.ValidationSummary(true) | ||
<fieldset> | ||
<legend>Chatting</legend> | ||
<div class="display-label right-float"></div> | ||
<div class="display-field right-float"> | ||
<h4>Users</h4> | ||
<ul> | ||
<select id="lb" style="width:250px" multiple="multiple" size="10"> </select> | ||
</ul> | ||
</div> | ||
<div class="display-label left-float"> MessageBoard</div> | ||
<div class="display-field left-float"> | ||
@Html.TextArea("Messages",new { @class = "messageBoard"}) | ||
</div> | ||
|
||
<div class="editor-label"> | ||
@Html.LabelFor(model => model.Message) | ||
</div> | ||
<div class="editor-field"> | ||
@Html.EditorFor(model => model.Message) | ||
@Html.ValidationMessageFor(model => model.Message) | ||
</div> | ||
<p> | ||
<input type="file" name="file" /> | ||
<input type="submit" value="OK" /> | ||
</p> | ||
|
||
|
||
|
||
</fieldset> | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters