[! use HTTP::File; !] [- $web_dir = $fdat{d}; # Ensure $web_dir ends with a '/' if (substr($web_dir,-1) eq '/') { $wd = substr($web_dir,-1) if $web_dir ne '/'; } else { $wd = $web_dir; $web_dir .= '/'; } $fdat{op} ||= 'Upload'; -] ewok directory [+ "\l$fdat{op}" +] [$ sub error $] [- $errors = shift; -]

[$ foreach $error (@$errors) $][+ $error +]
[$ endforeach $]

[$ endsub $] [# Error conditions #] [- @ops = qw(Create Update Upload Permissions Publishing); $fs_dir = $req_rec -> lookup_uri("$web_dir") -> filename; $fs_dir .= '/' if substr($fs_dir, -1) ne '/'; push @errors, "Error: cannot find directory $wd." if ! -d $fs_dir; push @errors, "Error: cannot write to directory $wd." if ! @errors && ! -w $fs_dir; error(\@errors) if @errors; -] [$ if (! @errors) $] [- if ($fdat{op} eq 'Upload' && $fdat{file} && $fdat{d}) { # Need to get a lock on the destination file if (HTTP::File::upload($fdat{file}, $fs_dir)) { my $fs_file = "$fs_dir$fdat{file}"; if ($fs_file =~ m/$Ewok::Config::EWOK_META_RE/i) { # Setup default metadata my $meta = getMetaCreate($fs_file); setMeta($fs_file, $meta) if defined $meta; } Ewok::DBILock::unlock($fs_file, $ENV{REMOTE_USER}, { altfile => "$web_dir$fdat{file}" }); $http_headers_out{Location} = "/ewok/fm.html?d=$web_dir"; } else { push @errors, "Error: file upload failed."; Ewok::DBILock::unlock("$fs_dir$fdat{file}", $ENV{REMOTE_USER}, { errors => \@errors, altfile => "$web_dir$fdat{file}" }); } } -] [# Non-fatal errors: display and reproduce appropriate form #] [$ if (! exists $http_headers_out{Location}) $] [- error(\@errors) if @errors; -] File upload to [+ $web_dir +]:
File: