version 1.257, 2002/07/30 21:20:27
|
version 1.258, 2002/07/31 13:50:38
|
Line 728 sub userfileupload {
|
Line 728 sub userfileupload {
|
$fname=~s/^.*\/([^\/]+)$/$1/; |
$fname=~s/^.*\/([^\/]+)$/$1/; |
unless ($fname) { return 'error: no uploaded file'; } |
unless ($fname) { return 'error: no uploaded file'; } |
chop($ENV{'form.'.$formname}); |
chop($ENV{'form.'.$formname}); |
|
# Create the directory if not present |
my $path='/userfiles/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/'; |
my $path='/userfiles/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/'; |
# |
my $filepath=$perlvar{'lonDocRoot'}; |
# FIXME: actually save file |
my @parts=split(/\//,$filepath.$path); |
# |
my $count; |
return 'http;//'.$ENV{'SERVER_NAME'}.$path.$fname; |
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 |
# ------------------------------------------------------------------------- Log |