Back to Stream class

Method upload

public mixed
upload
(mixed $src, mixed $dest, mixed $context = null, mixed $usePrefix = true, mixed $relative = false)
Upload a file
Parameters
  • string $src The file path to copy from (usually a temp folder).
  • string $dest The file path to copy to.
  • resource $context A valid context resource (optional) created with stream_context_create.
  • bool $usePrefix Controls the use of a prefix (optional).
  • bool $relative Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
Returns
  • mixed
Since
  • 1.7.0
Class: Stream
Project: Joomla

Method upload - Source code

/**
 * Upload a file
 *
 * @param   string    $src        The file path to copy from (usually a temp folder).
 * @param   string    $dest       The file path to copy to.
 * @param   resource  $context    A valid context resource (optional) created with stream_context_create.
 * @param   boolean   $usePrefix  Controls the use of a prefix (optional).
 * @param   boolean   $relative   Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
 *
 * @return  mixed
 *
 * @since   1.7.0
 */
public function upload($src, $dest, $context = null, $usePrefix = true, $relative = false)
{
    if (is_uploaded_file($src)) {
        // Make sure it's an uploaded file
        return $this->copy($src, $dest, $context, $usePrefix, $relative);
    } else {
        $this->setError(Text::_('JLIB_FILESYSTEM_ERROR_STREAMS_NOT_UPLOADED_FILE'));
        return false;
    }
}