NAME
GX::HTTP::Upload - HTTP upload class
SYNOPSIS
# Load the class
use GX::HTTP::Upload;
# Create a new upload object
$upload = GX::HTTP::Upload->new( '/tmp/0001.jpg' );
# Get the size in bytes of the upload
$bytes = $upload->size;
# Get the accompanying headers
$headers = $upload->headers;
# Get the name of the associated HTML form control
$name = $upload->name;
# Move the uploaded file
$upload->move( '/myapp/uploads/0001.jpg' );
# Disable file deletion on object destruction
$upload->cleanup( 0 );
DESCRIPTION
This module provides the "GX::HTTP::Upload class" which extends the GX::Class::Object class.
METHODS
Constructor
new
Returns a new GX::HTTP::Upload object.
$upload = GX::HTTP::Upload->new( %attributes );
- Attributes:
-
cleanup( bool )A boolean flag indicating whether or not to delete the uploaded file on destruction of the upload object. Defaults to true.
file( string )The path to the uploaded file.
filename( string )The client-supplied name of the uploaded file.
headers( GX::HTTP::Headers object )A GX::HTTP::Headers object containing the headers that accompanied the upload.
name( string )The name of the HTML form control associated with the upload.
- Returns:
-
$upload( GX::HTTP::Upload object )
- Exceptions:
Alternative syntax:
$upload = GX::HTTP::Upload->new( $file );
- Arguments:
-
$file( string )The path to the uploaded file.
- Returns:
-
$upload( GX::HTTP::Upload object )
- Exceptions:
Public Methods
cleanup
Returns / sets the cleanup flag.
$bool = $upload->cleanup;
$bool = $upload->cleanup( $bool );
file
Returns / sets the path to the uploaded file.
$file = $upload->file;
$file = $upload->file( $file );
filename
Returns / sets the client-supplied name of the uploaded file.
$filename = $upload->filename;
$filename = $upload->filename( $filename );
headers
Returns / sets the container object for the headers that accompanied the upload.
$headers = $upload->headers;
$headers = $upload->headers( $headers );
- Arguments:
-
$headers( GX::HTTP::Headers object |undef) [ optional ]
- Returns:
-
$headers( GX::HTTP::Headers object |undef)
move
Moves the uploaded file to the specified destination.
$upload->move( $destination, $overwrite );
Calling this method updates the file attribute and sets the cleanup flag to false.
name
Returns / sets the name of the HTML form control associated with the upload.
$name = $upload->name;
$name = $upload->name( $name );
open
Opens the uploaded file in the specified mode, returning an IO::File object on success.
$handle = $upload->open( $mode );
- Arguments:
-
$mode( string ) [ optional ]The open mode (">", "+<", etc.). If omitted, the file is opened in read-only mode.
- Returns:
-
$handle( IO::File object )
- Exceptions:
size
Returns the size of the uploaded file in bytes.
$size = $upload->size;
SEE ALSO
AUTHOR
Jörg A. Uzarek <uzarek@runlevelnull.de>
COPYRIGHT AND LICENSE
Copyright (c) 2009-2011 Jörg A. Uzarek.
This module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 as published by the Free Software Foundation.