Upload JPEG images/MPEG-4 videos to an HTTP server

Summary: This article describes the configuration of Axis cameras or video encoders that are able to upload single JPEG images or MPEG-4 videos to an HTTP server. This document also includes  information on how to configure the Apache web server on a Linux computer.
The information in this article applies to Axis cameras or video encoders that are able to upload single JPEG images or MPEG-4 videos to an HTTP server.

Instructions - Web server

  1. Create a directory on your host computer where the images from the camera are to be archived, e.g. /archive/images/. Please check that the directory is accessible by the web server application.
  2. Create an upload script in the cgi-bin directory of your Apache web server. Please check that the script is executable by the web server application.
  3. Modify the script by editing the upload directory in line 3 of the script. Save this script as e.g. upload.cgi

Here is an example script for the Apache server running under Linux:

#!/usr/bin/perl -w

my $upload_dir = "/var/www/cgi-bin/upload/";

print "Content-Type: text/plain\r\n\r\n";
print "Upload OK\r\n";

my $file_name = $ENV{'HTTP_CONTENT_DISPOSITION'};
$file_name =~ s/^attachment; filename=\"(.*)\"$/$1/;

open (IMG_FILE, "> $upload_dir$file_name") or die "can't open >$upload_dir$file_name";
binmode(IMG_FILE);
while (<STDIN>) {

    print IMG_FILE $_;

}
chmod 0666, "$upload_dir$file_name";

exit 0;

Instructions - Camera/Video Encoder

Please note that the capabilities of the camera or video encoder to upload images or videos to an HTTP server may differ depending on the model and firmware version. Also, the user interface of the camera or video encoder may differ from the example.

Configure the Event Server and Event

  1.  Go to Setup > Event > Event server in the camera/video encoder web interface.
  2. Add a new HTTP server.
  3. In the URL field you must enter the complete path to the script on your server:
    http://ip_address/cgi-bin/upload.cgi
  4. If authentication for cgi-script is enabled on your apache server, you must specify a user with access for the execution of the uploaded script. In this case the user will also need write permission in the upload directory.

Go to Setup > Event > Event Type and configure the event in the Axis camera/video encoder. Here is an example:

  1. Select HTTP as upload type and select the previously configured HTTP server from the drop-down list.
  2. Click OK to save the settings.
  3. The camera will upload images or videos to the HTTP server at the specified time interval. The images or videos are saved in the specified directory named according to the event type settings.

Disclaimer
Axis cannot be held responsible for the correctness or completeness of the information included in this document. The information is provided "as is" without warranty of any kind. Axis disclaims all warranties, whether express or implied, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, title and non-infringement, with respect to the information provided in this document.