Google
 
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.

NOTICES
       modules
              Make sure all the related modules are installed
              properly.  Please refer to the README file in the
              compressed file.

       enctype
              In the form tag, we must specify
              "enctype=multipart/form-data" to have HTTP File
              Upload supported, else your browser will not attach
              any selected file in the submission of form data.

       permission
              CGI script owner must have enough write privilege
              to save the uploaded file into the specified
              directory.

       allow_char
              For security reason, by default, FileUpload module
              only allows alphanumeric, dash and dot in filename.
              You might need to call allow_char function to allow
              characters like "/" or "\" if your file going to be
              saved outsides the current directory.

       deny_ext
              You might want to deny some file extensions to
              avoid users upload some virus/trojan files with
              this function.

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.

       0.04 -> 0.05   Checking of $newfh should be done after
       it's being assigned, should not be after the OS checking's
       if block.

       0.05 -> 0.06   Makefile.PL will check for IO module which
       is required.  And new() will return undef if an error
       occurred.

       0.06 -> 0.07   Some NOTICES are added to help the
       developers.

DOWNLOAD
       http://www.tneoh.zoneit.com/perl/FileUpload/download/

AUTHOR
       Simon Tneoh Chee-Boon   tneohcb@pc.jaring.my

       Copyright (c) 2000-2002 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

The CGI Resource
                  Index

Rate
           this Script @ The CGI Resource Index