How to upload image file alongside text with SQL server 2008
Hi all, fairly new to Umbraco and the MVC Framework. Been working on a upload form today and cannot for the life of me seem to get the image upload to work.
My Model:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Umbraco.Core.Persistence;
namespace UmbracoSite.Models
{
[TableName("UmbracoBadge")]
[PrimaryKey("badge_id", autoIncrement = true)]
public class Badges
{
public int badge_id { get; set; }
public string badge_name { get; set; }
public string badge_image { get; set; }
public string badge_desc { get; set; }
public DateTime added_date { get; set; }
public string BadgeImages
{
get { return badge_image.Replace(" ", string.Empty) + ".jpg"; }
}
}
}
My Controller:
using System;
using System.IO;
using System.Web;
using System.Web.Mvc;
using Umbraco.Web.Mvc;
using UmbracoSite.Models;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
namespace UmbracoSite.Controllers
{
public class BadgeSurfaceController : SurfaceController
{
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Umbraco.Core;
using Umbraco.Core.Persistence;
using UmbracoSite.Models;
namespace UmbracoSite
{
public class BadgeRepository
{
private readonly UmbracoDatabase _database;
public BadgeRepository()
{
_database = ApplicationContext.Current.DatabaseContext.Database;
}
public IList<Badges> Getall()
{
return _database.Fetch<Badges>("SELECT * FROM UmbracoBadge");
}
//[HttpPost]
//public ActionResult UploadPhoto(string badgeImages, HttpPostedFileBase photo)
//{
// string path = "~/images/BadgeImages/" + badgeImages;
// if (photo != null) photo.SaveAs(path);
// return CurrentUmbracoPage();
//}
public void Insert(Badges badge)
{
_database.Insert(badge);
}
}
How to upload image file alongside text with SQL server 2008
Hi all, fairly new to Umbraco and the MVC Framework. Been working on a upload form today and cannot for the life of me seem to get the image upload to work.
My Model:
using System.Collections.Generic; using System.Linq; using System.Web; using Umbraco.Core.Persistence;
namespace UmbracoSite.Models {
}
My Controller:
using System.IO; using System.Web; using System.Web.Mvc; using Umbraco.Web.Mvc; using UmbracoSite.Models; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Net;
namespace UmbracoSite.Controllers { public class BadgeSurfaceController : SurfaceController {
}
My view:
@using (Html.BeginUmbracoForm("AddBadge", "BadgeSurface", null, new { @class = "badge-form" })) {
}
I'm also using a repository for the Sql :
using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Umbraco.Core; using Umbraco.Core.Persistence; using UmbracoSite.Models;
namespace UmbracoSite { public class BadgeRepository { private readonly UmbracoDatabase _database;
}
Any help would be greatly appreciated!!
Thanks, Sam
is working on a reply...