[LON-CAPA-cvs] cvs: loncom /interface londocs.pm /lonnet/perl lonnet.pm
www
lon-capa-cvs@mail.lon-capa.org
Wed, 31 Jul 2002 13:50:38 -0000
www Wed Jul 31 09:50:38 2002 EDT
Modified files:
/loncom/interface londocs.pm
/loncom/lonnet/perl lonnet.pm
Log:
Course document upload
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.2 loncom/interface/londocs.pm:1.3
--- loncom/interface/londocs.pm:1.2 Wed Jul 24 16:40:58 2002
+++ loncom/interface/londocs.pm Wed Jul 31 09:50:38 2002
@@ -1,16 +1,31 @@
# The LearningOnline Network
# Documents
#
-# (Internal Server Error Handler
+# $Id: londocs.pm,v 1.3 2002/07/31 13:50:38 www Exp $
#
-# (Login Screen
-# 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
-# 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
+# Copyright Michigan State University Board of Trustees
#
-# 3/1/1 Gerd Kortemeyer)
+# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
-# 3/1 Gerd Kortemeyer
+# LON-CAPA is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
#
+# LON-CAPA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LON-CAPA; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# /home/httpd/html/adm/gpl.txt
+#
+# http://www.lon-capa.org/
+#
+
package Apache::londocs;
use strict;
@@ -22,15 +37,23 @@
$r->send_http_header;
return OK if $r->header_only;
-# --------------------------------------------------- Print login screen header
+ my $url;
+
+ if ($ENV{'form.uploaddoc.filename'}) {
+ $url=&Apache::lonnet::userfileupload('uploaddoc');
+ }
$r->print(<<ENDDOCUMENT);
<html>
<head>
<title>The LearningOnline Network with CAPA</title>
</head>
<body bgcolor="#FFFFFF">
-<h1>Printout</h1>
-<img src="/adm/lonKaputt/lonconstruct.gif">
+<h1>Course Documents</h1>
+<form method="post" enctype="multipart/form-data">
+<input type="file" name="uploaddoc" size="20">
+<input type="submit" value="Upload Document">
+</form>
+$url
</body>
</html>
ENDDOCUMENT
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.257 loncom/lonnet/perl/lonnet.pm:1.258
--- loncom/lonnet/perl/lonnet.pm:1.257 Tue Jul 30 17:20:27 2002
+++ loncom/lonnet/perl/lonnet.pm Wed Jul 31 09:50:38 2002
@@ -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 @@
$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