--- loncom/publisher/lonupload.pm 2011/11/02 14:40:16 1.57 +++ loncom/publisher/lonupload.pm 2015/09/11 20:12:30 1.67 @@ -1,8 +1,7 @@ - # The LearningOnline Network with CAPA # Handler to upload files into construction space # -# $Id: lonupload.pm,v 1.57 2011/11/02 14:40:16 raeburn Exp $ +# $Id: lonupload.pm,v 1.67 2015/09/11 20:12:30 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -126,7 +125,6 @@ use Apache::File; use File::Copy; use File::Basename; use Apache::Constants qw(:common :http :methods); -use Apache::loncacc; use Apache::loncommon(); use Apache::lonnet; use HTML::Entities(); @@ -163,7 +161,7 @@ sub upfile_store { } sub phaseone { - my ($r,$fn,$uname,$udom,$mode)=@_; + my ($r,$fn,$mode,$uname,$udom)=@_; my $action = '/adm/upload'; if ($mode eq 'testbank') { $action = '/adm/testbank'; @@ -175,7 +173,8 @@ sub phaseone { $env{'form.upfile.filename'}=~s/\\/\//g; $env{'form.upfile.filename'}=~s/^.*\/([^\/]+)$/$1/; if (!$env{'form.upfile.filename'}) { - $r->print('
'.&mt('No upload file specified.').'
'); + $r->print(''.&mt('No upload file specified.').'
'. + &earlyout($fn,$uname,$udom)); return; } @@ -189,6 +188,26 @@ sub phaseone { $r->print(''.&mt('Illegal filename.').'
'); return; } + # Check if quota exceeded + my $filesize = length($env{'form.upfile'}); + if (!$filesize) { + $r->print(''.
+ &mt('Unable to upload [_1]. (size = [_2] bytes)',
+ ''.$env{'form.upfile.filename'}.'',
+ $filesize).'
'.
+ &mt('Either the file you attempted to upload was empty, or your web browser was unable to read its contents.').'
'.
+ '
'.&mt('Or [_1]continue[_2] the testbank import without modifying the references(s).','','').'
'; + $result .= ''.&mt('Or [_1]continue[_2] the testbank import without modifying the reference(s).','','').'
'; } } } @@ -407,6 +426,9 @@ sub phasethree { my $url_root = "/priv/$udom/$uname"; my $dir_root = $r->dir_config('lonDocRoot').$url_root; my $path = &File::Basename::dirname($fn); + $path =~ s{^\Q$url_root\E}{}; + my $dirpath = $url_root.$path.'/'; + $dirpath=~s{/+}{/}g; my $filename = &HTML::Entities::encode($env{'form.filename'},'<>&"'); my $state = &embedded_form_elems('modify_orightml',$filename,$mode). ''; @@ -415,9 +437,9 @@ sub phasethree { $dir_root,$url_root,undef, undef,undef,$state,$action); if ($mode ne 'imsimport' && $mode ne 'testbank') { - $result .= '