GX::HTTP::Upload - HTTP upload class
# 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 );
This module provides the "GX::HTTP::Upload class" which extends the GX::Class::Object class.
new
Returns a new GX::HTTP::Upload object.
$upload = GX::HTTP::Upload->new( %attributes );
cleanup ( bool )
cleanup
A boolean flag indicating whether or not to delete the uploaded file on destruction of the upload object. Defaults to true.
file ( string )
file
The path to the uploaded file.
filename ( string )
filename
The client-supplied name of the uploaded file.
headers ( GX::HTTP::Headers object )
headers
A GX::HTTP::Headers object containing the headers that accompanied the upload.
name ( string )
name
The name of the HTML form control associated with the upload.
$upload ( GX::HTTP::Upload object )
$upload
GX::Exception
Alternative syntax:
$upload = GX::HTTP::Upload->new( $file );
$file ( string )
$file
Returns / sets the cleanup flag.
$bool = $upload->cleanup; $bool = $upload->cleanup( $bool );
$bool ( bool ) [ optional ]
$bool
$bool ( bool )
Returns / sets the path to the uploaded file.
$file = $upload->file; $file = $upload->file( $file );
$file ( string | undef ) [ optional ]
undef
$file ( string | undef )
Returns / sets the client-supplied name of the uploaded file.
$filename = $upload->filename; $filename = $upload->filename( $filename );
$filename ( string | undef ) [ optional ]
$filename
$filename ( string | undef )
Returns / sets the container object for the headers that accompanied the upload.
$headers = $upload->headers; $headers = $upload->headers( $headers );
$headers ( GX::HTTP::Headers object | undef ) [ optional ]
$headers
$headers ( GX::HTTP::Headers object | undef )
move
Moves the uploaded file to the specified destination.
$upload->move( $destination, $overwrite );
$destination ( string )
$destination
$overwrite ( bool ) [ optional ]
$overwrite
Defaults to false.
Calling this method updates the file attribute and sets the cleanup flag to false.
Returns / sets the name of the HTML form control associated with the upload.
$name = $upload->name; $name = $upload->name( $name );
$name ( string | undef ) [ optional ]
$name
$name ( string | undef )
open
Opens the uploaded file in the specified mode, returning an IO::File object on success.
$handle = $upload->open( $mode );
$mode ( string ) [ optional ]
$mode
The open mode (">", "+<", etc.). If omitted, the file is opened in read-only mode.
$handle ( IO::File object )
$handle
size
Returns the size of the uploaded file in bytes.
$size = $upload->size;
$size ( integer )
$size
GX::HTTP::Uploads
Jörg A. Uzarek <uzarek@runlevelnull.de>
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.
To install GX, copy and paste the appropriate command in to your terminal.
cpanm
cpanm GX
CPAN shell
perl -MCPAN -e shell install GX
For more information on module installation, please visit the detailed CPAN module installation guide.