Web Home

SDK Home


Test PHP

Test ASP









Contact Us


JavaSonics ListenUp is no longer for sale.

Writing Server Scripts to Receive Uploaded File

ListenUp sends the recorded message to the server as a file using an HTTP POST. The URL for the POST is that specified using the "uploadURL" Applet parameter. You can write your own scripts to receive the uploaded file and integrate it with your own web based application.

Note that any scripting language may be used on the server including PHP, JSP, ASP, Perl, etc. We have provided sample scripts for some languages in the SDK. These can be found in the test folders. Look, for example, in the "php_test" folder for "handle_upload_simple.php".

Upload Server Script Requirements (IMPORTANT)

The upload server scripts that you write must meet certain requirements. How you do that will depend on the scripting language that you use. More details will be given in the sections for specific languages.

  1. Set HTTP header flags, or modify URL each time, so that page output will not be cached.
  2. Set header flags so that the page will be transmitted as plain text that is easily parsed by ListenUp.
  3. Receive and process variables from POST command.
  4. Validate the uploaded information to make sure the file is not too large or has an illegal name. You decide what is legal.
  5. Receive uploaded file and, if it is acceptable, move it to the folder where you store recordings.
  6. Return a status line that starts with "SUCCESS", WARNING" or "ERROR".

Format of Uploaded Data

The Recorder Applet uploads its data using an HTTP POST in "multipart/form-data" MIME format. This is the same format that HTML FORMs use. In fact, to the server, ListenUp looks just like a submission from a FORM that includes an uploaded file. This allows one to use standard scripting techniques on the server to receive the file. Rather than duplicate existing documentation, I have included references to some available resources.

Simulate ListenUp using a FORM

To help you write your own server scripts, we have provided HTML code that simulates the ListenUp Applet. It contains an HTML FORM that uploads a file. This lets you develop and debug your server scripts without using ListenUp. More information here.

Uploaded Audio File

Note: the MIME field name for the uploaded file is "userfile". The uploaded file comes with a name but that is just a suggestion from the client. Your script is free to name the file anything you want. Click here for suggestions for naming files on the server.

The content type for Speex files is "audio/x-ogg".

The content type for WAV files is "audio/wav".

Additional Information Uploaded with the Audio File

The following variables are uploaded along with the recording.

"duration" = play time of the recording in seconds

You can also upload additional information as name/value pairs using hidden text fields. These could include user names, email addresses, etc.

Returning a Result from Your Script to ListenUp

The server script can send messages that will be displayed to the user. Any line beginning with the word "SUCCESS" or "ERROR" will be displayed in a label on the Applet. Any other output from the script will be echoed to the Java console by ListenUp for debugging. This return value is required in order for the JavaScript methods setUploadCompletionScript(script) or setUploadFailureScript(script) to be triggered.

Integration with a Database

Your upload script can interact with a database. You may want to use a database to keep track of uploaded messages. In that case, we recommend placing the recorded message file in a regular folder, and just putting the filename in the database.

Sending JavaScript Commands back to the Client

You can send a JavaScript command from the server to the Applet running on the client. Just output "CALLJS" at the beginning of a line followed by the JavaScript code. You will also need to set mayscript="true" in the Applet tag. For example, to pop up an alert message on the client from a PHP server script:

echo "CALLJS alert('Server says Hello using CALLJS');\n";

Continue with Your Server Language


If you are using another scripting language, then look in the documentation for that language of that language for keywords "upload file" and "POST" and "HTML FORM".

[Top] [Previous] [Next]

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