JavaSonics

SDK

Documentation


Web Home

SDK Home

Docs

Test PHP

Test ASP

Test ASP.NET

Examples

Demos

Download

Purchase

Support

Forum

Login

Contact Us

Company


Script to Generate a Unique Filename

Note this script is optional. There are also two other ways to specify the uploaded file name.

The Applet uses this script first in order to get a unique filename. This prevents collisions when multiple clients are uploading files at the same time. The script must return information to the Applet in a specific format in two lines of text:

  1. a line starting with the word "SUCCESS"
  2. a line containing the filename by itself
Any additional output will be echoed to the Java console for debugging.

If the first line does not start with SUCCESS then the line is assumed to contain error information and is displayed to the user.

Note that for testing purposes, a simple script could return a non-unique filename. Here is a PHP example:

<?
// Return a non-unique filename to client for testing.
// Tell browser we are sending text not HTML.
// These must come before anything else is printed so that
// they get in the header. 
    header("Cache-control: private");
    header("Content-Type: text/plain");

    echo "SUCCESS\n"; // indicate we got a valid filename
    echo "msg_123456.wav\n"; // the filename
    echo "Additional text will show up in the Java console.\n"; // for debugging
?>

A script for a real application could create a database record then generate a unique filename from the record ID. See "gen_unique_id.php" in the release package for an example.


© 2001-2006 Mobileer, Inc.   This page is from the ListenUp SDK. You can download the SDK from here.