Let us assume the situation when you already have a Web site and want to embed ActiveX/Java Uploader in it. For example, your server-side scripts parse the POST request in a strongly defined format, and, of course, you do not want to rewrite them to make compatible with ActiveX/Java Uploader. In this case you just need to configure the control to send the POST request in the necessary format.
As you know, ActiveX/Java Uploader sends files and additional data as POST fields. There are two kinds of these fields:
See the POST Field Reference topic for more details.
If a predefined format of standard POST fields is inconvenient for you, as in the situation described in the beginning of this article, you can rename them using the renameStandardField(String, String) method. This method uses two string parameters originalName and newName, where originalName is a name of some standard field and newName is its new name. Both parameters can contain particular indices or use the following placeholders:
[itemIndex]
is the current index of the uploaded file.[converterIndex]
is the current index of the converted file.The code sample below demonstrates how to rename standard POST fields and attach the additional fields to make ActiveX/Java Uploader compatible with server-side scripts which parse the POST request in the following format:
var u = $au.uploader({ id: 'Uploader1', converters: [ { mode: '*.*=SourceFile'}, { mode: '*.*=Thumbnail;*.*=Icon', thumbnailFitMode: 'Fit', thumbnailWidth: '120', thumbnailHeight: '120' }, { mode: '*.*=Thumbnail;*.*=Icon', thumbnailFitMode: 'Fit', thumbnailWidth: '640', thumbnailHeight: '480' } ], //... other parameters ... }); u.metadata().addCustomField("Author", author); u.metadata().renameStandardField("PackageFileCount", "Number"); u.metadata().renameStandardField("File0_[itemIndex]", "File[itemIndex]"); u.metadata().renameStandardField("Description_[itemIndex]", "File[itemIndex]-Description"); u.metadata().renameStandardField("File[converterIndex]_[itemIndex]", "File[itemIndex]-Thumbnail[converterIndex]"); u.metadata().renameStandardField("File[converterIndex]Size_[itemIndex]", "File[itemIndex]-Thumbnail[converterIndex]-Size"); u.metadata().renameStandardField("File[converterIndex]Width_[itemIndex]", "File[itemIndex]-Thumbnail[converterIndex]-Width"); u.metadata().renameStandardField("File[converterIndex]Height_[itemIndex]", "File[itemIndex]-Thumbnail[converterIndex]-Height"); u.writeHtml();
Renamed fields cannot be retrieved using the PostFields constants.