HuwD
HuwD

Reputation: 1810

dnn filepickeruploader control

Am developing a module for DotNetNuke 7. I want to be able to upload a thumbnail image for entries in a catalogue. Have managed place control in edit view of my module and upload and select files however when I build the project I get the following error:

C:\dnn\dotnetnuke\DesktopModules\EventCatalog\Edit.ascx.designer.cs(103,38,103,41): error CS0234: The type or namespace name 'Web' does not exist in the namespace 'DotNetNuke' (are you missing an assembly reference?)

Also I can't figure out how to get the selected file on the backend to save the url to database. When I enter the ID of the control VS recognizes it but intellisense doesn't provide any clues as possible options.

Can anyone tell me how to fix the above error and also if possible, point me towards a overview/tutorial for this control. Have done a fair amount of Googling but not found anything.

Upvotes: 2

Views: 2090

Answers (2)

Wes Tatters
Wes Tatters

Reputation: 1

The built in dnn upload control is specifically designed for uploading files to the dnn file system - but to be honest its pretty ugly to work with.

It makes a lot of assumptions about what you want to do with the file and as part of its process automatically registers new file in the dnn file system index.

Its also not really ideal for thumbnail uploads or any such fancy stuff - since it has no capability for file size management or scaling and cropping - its something that has been promised a couple of times but not eventuated to date.

On top of this is has a bit of a mind of its own when it comes to where it actually stores the uploaded file - which means you may be better off looking at a 3rd party uploader that you can control more easily.

FWIW - there is a full version of the telerik asyn upload library installed with every dnn install - you will need to setup it up manually but that is not that hard.

<dnn:DnnAsyncUpload></dnn:DnnAsyncUpload> is the markup basic structure and its functionally equivalent to <telerik:RadAsyncUpload></telerik:RadAsyncUpload>

Its documented here http://www.telerik.com/help/aspnet-ajax/asyncupload-overview.html

Having said all this if you do want to stick with dnn file picker - this code will let you find the file object that dnn uploaded the file too.

String thisURL = "";
String thisPHYSICAL = "";
Int32 itest001 = thisControl001.FileID;
if ( itest001 > 0 )
{
    var thisFILE = (DotNetNuke.Services.FileSystem.FileInfo)FileManager.Instance.GetFile(itest001);
    thisURL = FileManager.Instance.GetUrl(thisFILE );
    thisPHYSICAL = thisURL.PhysicalPath;
}

thisURL will contain a url relative to your website domain thisPHYSICAL will contain the physical location of the file on your server.

Upvotes: 0

bdukes
bdukes

Reputation: 156005

Well, to start, you probably need to add an assembly reference to DotNetNuke.Web to your project. Once that's there, it'll probably help with your lack of intellisense as well.

Looks like the main way you interact with the selected URL is via the FileID property. The control itself will manage saving the file to the selected FolderPath (which may or may not be something the user can change).

But, you're right, there aren't good resources for how to use the control. The best "tutorial" it probably looking through the DotNetNuke core code to see how the core uses the control.

Upvotes: 1

Related Questions