--- loncom/lonnet/perl/lonnet.pm 2002/07/30 21:20:27 1.257 +++ loncom/lonnet/perl/lonnet.pm 2002/07/31 13:50:38 1.258 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.257 2002/07/30 21:20:27 www Exp $ +# $Id: lonnet.pm,v 1.258 2002/07/31 13:50:38 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -728,11 +728,24 @@ sub userfileupload { $fname=~s/^.*\/([^\/]+)$/$1/; unless ($fname) { return 'error: no uploaded file'; } chop($ENV{'form.'.$formname}); +# Create the directory if not present my $path='/userfiles/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/'; -# -# FIXME: actually save file -# - return 'http;//'.$ENV{'SERVER_NAME'}.$path.$fname; + my $filepath=$perlvar{'lonDocRoot'}; + my @parts=split(/\//,$filepath.$path); + my $count; + for ($count=4;$count<=$#parts;$count++) { + $filepath.="/$parts[$count]"; + if ((-e $filepath)!=1) { + mkdir($filepath,0777); + } + } +# Save the file + { + my $fh=Apache::File->new('>'.$filepath.'/'.$fname); + print $fh $ENV{'form.'.$formname}; + } +# Return the URL to it + return 'http://'.$ENV{'SERVER_NAME'}.$path.$fname; } # ------------------------------------------------------------------------- Log