Configuring POST Format

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:

  • Author means author of the uploaded file.
  • Number means number of the uploaded file.
  • FileN is original file, where N is an index of this file.
  • FileN-Description is description of the Nth uploaded file.
  • FileN-ThumbnailX is the Xth thumbnail for the Nth uploaded image, or icon for non-image files.
  • FileN-ThumbnailX-Size is size of the Xth thumbnail of the Nth uploaded image.
  • FileN-ThumbnailX-Width is width of the Xth thumbnail of the Nth uploaded image.
  • FileN-ThumbnailX-Height is height of the Xth thumbnail of the Nth uploaded image.
JavaScript
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();
Note

Renamed fields cannot be retrieved using the PostFieldsPostFields (ASP.NET)PostFields (PHP) constants.

See Also

Reference

Manual