By submitting PHP Resources you own, or know of, you'll help us build the largest PHP Resource website on the net. Please double check that your resource doesn't already exist before you submit it!!. We thank you for helping make this a better website.
If no value for name is provided, then this
method will return an array containing all available information
about the uploaded file. Otherwise the information identified by
the value of this parameter will be returned as a string.
The list of possible values is determined by the contents of the
$_FILES array, but is customized for the purposes
of HTTP_Upload. Here are the possible properties:
'name': destination file name
'tmp_name': temporary uploaded file name (assigned by PHP)
'form_name': name of the HTML form that submitted the uploaded file
'type': Mime type of the file
'size': size of the file
'error': if there was an error on upload, this contains a string
representing the kind of error. The errorCode() method can be used
to retrieve a localized error message from this property.
Another handy feature of HTTP_Upload is
support for internationalized error messages. This means that if
an error (like an invalid file upload) is detected, the programmer
can choose in which the language the error messages should be returned
by HTTP_Upload.
The first parameter of the constructor method for
HTTP_Upload determines the language to be
used. This is illustrated in the following example:
// German error messages
$language = "de";
require_once "HTTP/Upload.php";
$upload = new HTTP_Upload($language);
$file = $upload->getFiles("f");
if ($file->isValid()) {
$moved = $file->moveTo("uploads/");
if (!PEAR::isError($moved)) {
echo "File was moved to uploads/";
} else {
// This will print a german error message
echo "An error was detected: " . $moved->getMessage() . "<br />";
}
}