[Xitami] upload
Joseph Saunders
xitami@lists.xitami.org
Fri, 3 Aug 2001 08:53:41 -0700
There are perl scripts available for uploading via http.
Heres an example:
NAME
FileUpload - Module for HTTP File Uploading.
TEST
http://www.tneoh.zoneit.com/perl/FileUpload/form.html
SYNOPSIS
use strict;
use FileUpload;
use CGI qw(-private_tempfiles :standard);
use vars qw($q $fu);
$q = new CGI;
$fu = new FileUpload($cgi->param('ufile'));
# The uploaded file's size.
$size = $fu->size;
# Get the filename.
$filename = $fu->orig_filename;
# Get the full path of the file.
# eg result: C:\test.html
$filepath = $fu->orig_filepath;
# Get the characters allowed.
@chararr = $fu->allow_char;
# Add the characters allowed.
@chararr = $fu->allow_char('char1', 'char2');
# Get the extensions not allowed.
@extarr = $fu->deny_ext;
# Add the extensions not allowed.
@extarr = $fu->deny_ext('cgi', 'shtml');
# Save the uploaded file as the original filename.
$byteswritten = $fu->save;
# Save the uploaded file by using "newfilename".
$byteswritten = $fu->save_as("newfilename");
# Get the filehandle's current position.
$pos = $fu->get_pos;
# Set the filehandle position.
$fu->set_pos($newpos);
# Read a line.
$aline = $fu->get_line;
# Read many lines.
@lines = $fu->get_lines;
DESCRIPTION
This module helps you to process uploaded file easier.
new UPLOADEDFILE
UPLOADEDFILE is the value returned by CGI->param() for
the uploaded file.
allow_char CHAR1, [CHAR2...]
CHAR1, [CHAR2...] are the characters that allowed for
the saved filename. Defaults are "\w", "\-" and "\.".
This is using regular expression's pattern match, so
please check "perldoc perlre" for more details of
patterns defined. Returns the array of the characters
allowed.
deny_ext EXT1, [EXT2...]
EXT1, [EXT2...] are the extensions that the saved
filename can not end with. Returns the array of the
extensions not allowed.
get_line
Read a line from the uploaded file.
get_lines
Read multiple lines from the uploaded file. Returns
an array of strings.
get_pos
Returns the current position for uploaded file's
FILEHANDLE.
orig_filename
Returns the original filename string.
orig_filepath
Returns the filepath string, eg result: C:\test.html.
save
Save the uploaded file as the original filename.
Returns the number of bytes actually wrote, or undef
if there was an error.
save_as NEWFILEPATH
Save the uploaded file to the NEWFILEPATH. Returns
the number of bytes actually wrote, or undef if there
was an error.
set_pos POSITION
Set the current position of filehandle to POSITION.
Returns 1 upon success, 0 otherwise.
size
Returns the size of the uploaded file upon success,
undef otherwise.
CHANGES
0.01 -> 0.02 orig_filename() returns a wrong filename.
0.02 -> 0.03 save_as() use read() now instead of
sysread() to solve some reading errors.
0.03 -> 0.04 Call the binmode() when we read and write
for files in Win32 platforms.
DOWNLOAD
http://www.tneoh.zoneit.com/perl/FileUpload/download/
AUTHOR
Simon Tneoh Chee-Boon tneohcb@pc.jaring.my
Copyright (c) 2000 Simon Tneoh Chee-Boon. All rights
reserved. This program is free software; you can
redistribute it and/or modify it under the same terms as
Perl itself.
SEE ALSO
CGI, IO::Handle and IO::File
-----Original Message-----
From: Andreas Zieritz [mailto:zieritz@sovik.no]
Sent: Friday, August 03, 2001 4:26 AM
To: Xitami
Subject: [Xitami] upload
I'm running Xitami as an http and ftp server on Linux.
Currently I'm using ftp for uploading things on it, but due to a
firewall problem some of our customers can't do upload. If someone could
give me a clue how to use http for upload I would very much appreciate
that.
Thank you in advance...
--
Servus,
Andreas
------------------------
Andreas Zieritz
Siviling. Svein Sovik AS
Fantoftveien 42
N-5072 Bergen
http://www.sovik.no
--
Xitami Users Mailing List -- For Xitami support
To unsubscribe: http://lists.xitami.org/mailman/listinfo/xitami