How to use MultiFileUploader control in a form

Carlos Pascual asked on November 4, 2014 15:57

Hi,

I have been using the new version of Kentico 8 and I am having some problems with the cms control MultiFileUploader.

I want to develop a form in asp.net that takes some parameters (name, amount, pictures) and store them in a page type. I have managed to create the form and create the page type with the name and the amount fields. But I am not able to upload the pictures in the system and obtain the GUIDs for the uploaded files.

In my form I have specified the following control:

<cms:MultiFileUploader ID="fileUploader" runat="server" UploadMode="Grid" Multiselect="true" SourceType="MetaFile" IsInsertMode="true" Width="100%">
                <AlternateContent>
                    <cms:LocalizedLabel ID="lblNoSilverlight" runat="server" ResourceString="fileimport.nosilverlight" CssClass="InfoLabel" />
                </AlternateContent>
</cms:MultiFileUploader> 

It is specified as a MetaFile and the IsInsertMode is true. Maybe these are not the correct values.

On the code for this site the initialization is as follows:

private void InitializeUploader()
{
    var picturesNode = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/LandingPages", "en-US");
    string uploadParams = String.Format("NodeID|{0}|DocumentCulture|{1}|IncludeExtension|{2}|NodeGroupID|0", picturesNode.NodeID, "en-US", true);
    uploadParams += "|Hash|" + ValidationHelper.GetHashString(uploadParams, false);

    string script = String.Format(@"var hdnUploaderOptions = document.getElementById('{0}_hdnUploaderOptions');
            if (hdnUploaderOptions) {{
                hdnUploaderOptions.value = '{1}';
            }}", fileUploader.ClientID, uploadParams);

    ScriptHelper.RegisterStartupScript(Page, typeof(string), "UploaderInit", script, true);
}

Am I using correctly the control to upload files? How can I obtain the GUIDs for the uploaded files? Please help me. I could not find any other answer or further information in the documentation. Thanks in advance!!

Carlos

Recent Answers


Lubos Rychtecky answered on December 9, 2014 12:37

Hi Carlos, if you want to use the MultiFileUploader control, you have to specify SiteID, ObjectID and ObjectType of the object to which uploaded files are to be assigned, instead of NodeID, DocumentCulture and NodeGroupID. Uploaded file is automatically assigned to this object. Alternatively you can use Metafile List form control or if you don't insist on metafiles you can use Attachments control.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.