[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm

www lon-capa-cvs@mail.lon-capa.org
Tue, 30 Jul 2002 21:20:27 -0000


www		Tue Jul 30 17:20:27 2002 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  Start of routine to load user file into userfile space, which will later
  have token-security.
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.256 loncom/lonnet/perl/lonnet.pm:1.257
--- loncom/lonnet/perl/lonnet.pm:1.256	Tue Jul 30 15:59:32 2002
+++ loncom/lonnet/perl/lonnet.pm	Tue Jul 30 17:20:27 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.256 2002/07/30 19:59:32 albertel Exp $
+# $Id: lonnet.pm,v 1.257 2002/07/30 21:20:27 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -717,6 +717,23 @@
 	'token='.$token.'&server='.$perlvar{'lonHostID'};
 }
     
+# --------------- Take an uploaded file and put it into the userfiles directory
+# input: name of form element
+# output: url of file in userspace
+
+sub userfileupload {
+    my $formname=shift;
+    my $fname=$ENV{'form.'.$formname.'.filename'};
+    $fname=~s/\\/\//g;
+    $fname=~s/^.*\/([^\/]+)$/$1/;
+    unless ($fname) { return 'error: no uploaded file'; }
+    chop($ENV{'form.'.$formname});
+    my $path='/userfiles/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/';
+#
+# FIXME: actually save file
+#
+    return 'http;//'.$ENV{'SERVER_NAME'}.$path.$fname;    
+}
 
 # ------------------------------------------------------------------------- Log