--- loncom/interface/loncommon.pm 2017/08/11 00:32:07 1.1289 +++ loncom/interface/loncommon.pm 2017/08/11 18:58:16 1.1290 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1289 2017/08/11 00:32:07 raeburn Exp $ +# $Id: loncommon.pm,v 1.1290 2017/08/11 18:58:16 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -13670,20 +13670,21 @@ sub upfile_store { =pod -=item * &load_tmp_file($r) +=item * &load_tmp_file($r,$datatoken) Load uploaded file from tmp, $r should be the HTTP Request object, -needs $env{'form.datatoken'}, +$datatoken is the name to assign to the temporary file. sets $env{'form.upfile'} to the contents of the file =cut sub load_tmp_file { - my $r=shift; + my ($r,$datatoken) = @_; + return if ($datatoken eq ''); my @studentdata=(); { my $studentfile = $r->dir_config('lonDaemons'). - '/tmp/'.$env{'form.datatoken'}.'.tmp'; + '/tmp/'.$datatoken.'.tmp'; if ( open(my $fh,"<$studentfile") ) { @studentdata=<$fh>; close($fh); @@ -13692,6 +13693,14 @@ sub load_tmp_file { $env{'form.upfile'}=join('',@studentdata); } +sub valid_datatoken { + my ($datatoken) = @_; + if ($datatoken =~ /^$match_username\_$match_domain\_enroll_$match_courseid\_\d+_\d+$/) { + return $datatoken; + } + return; +} + =pod =item * &upfile_record_sep()