diff options
author | jeff <jeff> | 2008-04-15 20:47:59 +0000 |
---|---|---|
committer | jeff <jeff> | 2008-04-15 20:47:59 +0000 |
commit | 6a24254d490f3d023728044daba0765f20f6971e (patch) | |
tree | c486026468a4e33092ae54925ff19b8e5dc7411b /httemplate/misc/file-upload.html | |
parent | bdbfd5c5a3bb7bc193b82dc39b98ae9ffe99da44 (diff) |
(finally) wrap up new tax rate engine (for now)
Diffstat (limited to 'httemplate/misc/file-upload.html')
-rw-r--r-- | httemplate/misc/file-upload.html | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/httemplate/misc/file-upload.html b/httemplate/misc/file-upload.html new file mode 100644 index 000000000..9649d3663 --- /dev/null +++ b/httemplate/misc/file-upload.html @@ -0,0 +1,47 @@ +<% include('/elements/header-minimal.html', 'File Upload') %> +% if ($error) { +Error: <% $error %> +% }else{ +Freeside File Upload Successful <% join(',', @filenames) %>; +% } +<% include('/elements/footer.html') %> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Import'); #? + +my @filenames = (); +my $error = ''; # could be extended to the access control + +$cgi->param('upload_fields') =~ /^([,\w]+)$/ + or $error = "invalid upload_fields"; +my $fields = $1; + +my $dir = $FS::UID::conf_dir. "/cache.". $FS::UID::datasrc; + +foreach my $field (split /,/, $fields) { + next if $error; + + my $fh = $cgi->upload($field) + or $error = "No valid file was provided."; + + my $sh = new File::Temp( TEMPLATE => 'upload.XXXXXXXX', + DIR => $dir, + UNLINK => 0, + ) + or $error ||= "can't open temporary file to store upload: $!\n"; + + unless ($error) { + while(<$fh>) { + print $sh $_; + } + $sh->filename =~ m!.*/([.\w]+)$!; + push @filenames, "$field:$1"; + close $sh + } + +} + +$error = "No files" unless scalar(@filenames); + +</%init> |