#!/usr/bin/perl /usr/bin/asp-perl This example shows you how to use Apache::ASP to handle file uploads. You need to have a recent version CGI.pm to use this facility. Just click Browse..., select your file, hit 'file upload' and voila!, you will see the data in the file below.

Note that the current limit set on uploads for this demo is <% my $limit = $Server->Config('FileUploadMax') || $CGI::POST_MAX; $limit = ($limit eq '-1') ? 'NONE' : $limit; print "$limit"; %> . <% if($limit && ($limit < $Request->{TotalBytes})) { %> This limit was exceeded by a POST of <%= $Request->{TotalBytes} %> bytes! <% } %>
<% use CGI; my $q = new CGI; print $q->start_multipart_form(); print $q->hidden('file_upload', 'Hidden File Upload Form Text'); print $q->filefield('uploaded_file','starting value',30,100); print ""; print $q->submit('Upload File'); %>

File Upload Type: <%= $q->checkbox_group(-name=>'extensions', -values=>['GIF','HTML','OTHER'], -defaults=>['HTML'] ) %> <% my $filehandle; if($filehandle = $Request->{Form}{uploaded_file}) { %> Upload Type Specified: <%= join(', ', $Request->Form('extensions')) %>
<% local *FILE; my $upload = $Request->{FileUpload}{uploaded_file}; print ""; my @data = ( '$Request->{TotalBytes}', $Request->{TotalBytes}, 'Hidden Text', $Request->Form('file_upload'), 'Uploaded File Name', $filehandle, # we only have the temp file because of the # FileUploadTemp setting 'Temp File', $upload->{TempFile}, 'Temp File Exists', (-e $upload->{TempFile}), 'Temp File Opened', (open(FILE, $upload->{TempFile}) ? 'yes' : "no: $!"), map { ($_, $Request->FileUpload('uploaded_file', $_)) } sort keys %$upload ); close FILE; while(@data) { my($key, $value) = (shift @data, shift @data); %> <% } print "
<%=$key%> <%=$value%>
"; %>

UPLOADED DATA
=============
<% 
    while(<$filehandle>) { 
	print $Server->HTMLEncode($_);	
    }
%>
	
<% } %>