Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Dmitry  
#1 Posted : Tuesday, August 18, 2009 12:03:25 AM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,068

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Some of our clients ask our support team whether Upload Suite can be used in ASP.NET MVC. The answer is “yes, it can be used in this framework”. In this knowledge base article you can find a simple project showing how to integrate Upload Suite ASP.NET control into ASP.NET MVC project. Further in this article I will highlight several aspects of using Upload Suite with ASP.NET MVC.

Suppose we have Uploader view (/views/home/uploader.aspx) where we are intended to enable upload functionality. The only thing we need to do is to add Upload Suite ASP.NET control to this page and write server script receiving uploaded data. So this way this page will be responsible for both displaying Upload Suite client-side and receiving data sent by users. The page will look like this:
Code:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Register Assembly="Aurigma.ImageUploader" Namespace="Aurigma.ImageUploader" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	AlbumUpload
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<script runat="server">
		private void ImageUploader1_FileUploaded(object sender, FileUploadEventArgs e)
		{
                …
		}

		protected void form1_Load(object sender, EventArgs e)
		{
			ImageUploader1.Action = "~/Home/Uploader/";
		}
	</script>

	<h2>
		AlbumUpload</h2>
	<form id="form1" runat="server" onload="form1_Load">
	<cc1:ImageUploader ID="ImageUploader1" runat="server" Width="650" Height="400" 
                PaneLayout="TwoPanes" ShowDebugWindow="true" AllowRotate="false" 
                BackgroundColor="#ffffff" 
                LicenseKey="XXXXX-XXXXX-XXXXX-XXXXX-XXXXX;XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"
                UploadThumbnail1FitMode="Fit" UploadThumbnail1Width="120" UploadThumbnail1Height="120"
                UploadThumbnail1JpegQuality="60" OnFileUploaded="ImageUploader1_FileUploaded">
	</cc1:ImageUploader>
	</form>
</asp:Content>

ImageUploader1_FileUploaded event handler is fired every time when a file is completely uploaded to a server, it should contain logic for saving files server-side. Another interesting method is form1_Load. As you can see it is Form.OnLoad event handler. Here we initialize Action property of Upload Suite control. This is the major point in this entire story. Due to peculiarities of MVC functioning we need to specify a page that receives upload on server side manually. Take into account that it is the same uploader.aspx set via controller-action.

I hope this sample will be helpful for all who are willing to integrate Upload Suite with ASP.NET MVC application.

Edited by moderator Tuesday, October 01, 2013 10:18:05 PM(UTC)  | Reason: Not specified

File Attachment(s):
uploader_mvc.zip (5,084kb) downloaded 686 time(s).
Sincerely yours,
Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!
mcselasvegas  
#2 Posted : Tuesday, April 06, 2010 5:41:42 AM(UTC)
mcselasvegas

Rank: Newbie

Groups: Member
Joined: 4/18/2009(UTC)
Posts: 3

Hi Dmitry,

This is great... I am just wondering if I can use the UIembeded versions as well...
I would like to customize the interface a little bit...

Code:

<script type="text/javascript">
			    var iu = new ImageUploaderWriter("ImageUploader1", "800", "600");
			    iu.activeXControlCodeBase = "/ImageUploader/ImageUploader6.cab";
			    iu.javaAppletJarFileName = "ImageUploader6.jar";
			    iu.javaAppletCodeBase = "/ImageUploader/";
			    iu.javaAppletCached = true;
			    iu.javaAppletCached = true;
			    iu.showNonemptyResponse = "off";
			    iu.addParam("PaneLayout", "ThreePanes");

			    iu.addParam("FileMask", "*.jpg;*.jpeg;*.jpe;*.bmp;*.gif");


			    iu.addParam("ShowDebugWindow", "true");
			    iu.addParam("AllowRotate", "false");
			    iu.addParam("AllowAutoRotate", "true");
			    iu.addParam("BackgroundColor", "#ffffff");
			    iu.addParam("AllowDisproportionalExifThumbnails", "false");
			    iu.addParam("ShowButtons", "false");
			    iu.addParam("ShowDescriptions", "false");
			    iu.addParam("LicenseKey", "XXX");
			    iu.addParam("UploadThumbnail1FitMode", "Fit");
			    iu.addParam("UploadThumbnail1Width", "150");
			    iu.addParam("UploadThumbnail1Height", "150");
			    iu.addParam("FilesPerOnePackageCount", "1");
			    iu.addParam("MessageUploadCompleteText", "");
			    iu.addParam("Action", "<%= me.ActionURL %>");
			    iu.addParam("RedirectUrl", "<%= me.RedirectURL %>");

			    iu.addEventListener("BeforeUpload", "beforeUpload");

			    iu.writeHtml();
			</script>


<a href="#" onclick="getImageUploader('ImageUploader1').Send();"><span>Upload Photos</span></a>


can I do something like this as well in mvc?
andreym  
#3 Posted : Tuesday, April 06, 2010 7:40:05 PM(UTC)
andreym

Rank: Advanced Member

Groups: Member
Joined: 6/16/2009(UTC)
Posts: 134

Was thanked: 8 time(s) in 8 post(s)
Hello!

Yes you can. Put the javascript code into the view and set the Action property to the controler and action which handle the upload.

By the way, the uploader asp.net control also support customization of the interface. You can find the list of properties which supported by asp.net control here.

Edited by user Tuesday, April 06, 2010 9:13:23 PM(UTC)  | Reason: Not specified

mcselasvegas  
#4 Posted : Wednesday, April 07, 2010 4:34:16 AM(UTC)
mcselasvegas

Rank: Newbie

Groups: Member
Joined: 4/18/2009(UTC)
Posts: 3

Hi andreym,

sounds good... I am just not sure how the code in the controller needs to look like to get this to work.
can you show me a sample of the code needed in the controller to get this to work?

Thank you
andreym  
#5 Posted : Wednesday, April 07, 2010 9:07:03 PM(UTC)
andreym

Rank: Advanced Member

Groups: Member
Joined: 6/16/2009(UTC)
Posts: 134

Was thanked: 8 time(s) in 8 post(s)
Hello!

I've prepared a simple demo for uploading files with Image Uploader within ASP.NET MVC application. It allows to upload files and save them in the folder. You can found it in the attached archive.

We add Uploader view and controller. Add two actions in the Uploader controller: Index and Upload. The Index action renders Image Uploader view, the Upload action contain the code to save uploaded files.
File Attachment(s):
iu_mvc_demo.zip (2,548kb) downloaded 388 time(s).
mcselasvegas  
#6 Posted : Thursday, April 08, 2010 1:55:19 PM(UTC)
mcselasvegas

Rank: Newbie

Groups: Member
Joined: 4/18/2009(UTC)
Posts: 3

You are the man... Just what I was looking for... Thank you so very much.
Mustafa Yuce  
#7 Posted : Wednesday, January 12, 2011 7:46:52 AM(UTC)
Mustafa Yuce

Rank: Newbie

Groups: Member
Joined: 12/27/2010(UTC)
Posts: 1

Dear andreym,

Your project works with Aurigma v6.5, but doesn't work with new v7.0.
I tried to replace binaries and scripts and result is unfortunately negative.
have you written an example for Aurigma v7.0?

Thank you very much...

Edited by user Wednesday, January 12, 2011 7:48:53 AM(UTC)  | Reason: Not specified

andreym  
#8 Posted : Wednesday, January 12, 2011 10:46:55 PM(UTC)
andreym

Rank: Advanced Member

Groups: Member
Joined: 6/16/2009(UTC)
Posts: 134

Was thanked: 8 time(s) in 8 post(s)
Hello Mustafa!

Image Uploader 7 have new api, so the demo from the first post should be rewritten with the new syntax. I've attached the working demo in this post.
File Attachment(s):
uploader_mvc_7.zip (5,444kb) downloaded 264 time(s).
umarmalik  
#9 Posted : Monday, March 05, 2012 6:13:34 AM(UTC)
umarmalik

Rank: Newbie

Groups: Member
Joined: 3/5/2012(UTC)
Posts: 2

Please HELP!!!

I have a MVC web application that needs to upload pictures using IPAD. Means IPAD users will access the web application and then upload pictures. I have done the implementation but get an error while uploading the pictures. "Redirect has been not enabled for this website". its frustrating please help. redirectionurl????? i am calling another view but still get the error
Andrew  
#10 Posted : Tuesday, October 01, 2013 8:03:57 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 778

Thanks: 2 times
Was thanked: 19 time(s) in 19 post(s)
I have just posted an updated ASP.NET MVC sample application which is implemented closer to the MVC ideology than this one. Hopefully everyone will find it useful.

See updated ASP.NET MVC sample application for Upload Suite 8
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF 2.1.0 | YAF © 2003-2014, Yet Another Forum.NET
This page was generated in 0.388 seconds.