![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
16/02/2008, 23:45
|
![Avatar de elfran222](http://static.forosdelweb.com/customavatars/avatar140503_1.gif) | | | Fecha de Ingreso: junio-2006
Mensajes: 550
Antigüedad: 18 años, 8 meses Puntos: 7 | |
Re: Subir Imagen Continuación class.upload.php
Código:
} else {
// this is an element from $_FILE, i.e. an uploaded file
$this->log .= '<b>source is an uploaded file</b><br />';
if ($this->uploaded) {
$this->file_src_error = $file['error'];
switch($this->file_src_error) {
case 0:
// all is OK
$this->log .= '- upload OK<br />';
break;
case 1:
$this->uploaded = false;
$this->error = $this->translate('uploaded_too_big_ini');
break;
case 2:
$this->uploaded = false;
$this->error = $this->translate('uploaded_too_big_html');
break;
case 3:
$this->uploaded = false;
$this->error = $this->translate('uploaded_partial');
break;
case 4:
$this->uploaded = false;
$this->error = $this->translate('uploaded_missing');
break;
default:
$this->uploaded = false;
$this->error = $this->translate('uploaded_unknown');
}
}
if ($this->uploaded) {
$this->file_src_pathname = $file['tmp_name'];
$this->file_src_name = $file['name'];
if ($this->file_src_name == '') {
$this->uploaded = false;
$this->error = $this->translate('try_again');
}
}
if ($this->uploaded) {
$this->log .= '- file name OK<br />';
ereg('\.([^\.]*$)', $this->file_src_name, $extension);
if (is_array($extension)) {
$this->file_src_name_ext = strtolower($extension[1]);
$this->file_src_name_body = substr($this->file_src_name, 0, ((strlen($this->file_src_name) - strlen($this->file_src_name_ext)))-1);
} else {
$this->file_src_name_ext = '';
$this->file_src_name_body = $this->file_src_name;
}
$this->file_src_size = $file['size'];
$this->file_src_mime = $file['type'];
// if the file is an image, we gather some useful data
if (array_key_exists($this->file_src_mime, $this->image_supported)) {
$this->file_is_image = true;
$this->image_src_type = $this->image_supported[$this->file_src_mime];
$info = @getimagesize($this->file_src_pathname);
}
}
}
// if the file is an image, we gather some useful data
if ($this->file_is_image) {
if (is_array($info)) {
$this->image_src_x = $info[0];
$this->image_src_y = $info[1];
$this->image_src_pixels = $this->image_src_x * $this->image_src_y;
$this->image_src_bits = array_key_exists('bits', $info) ? $info['bits'] : null;
} else {
$this->log .= '- can\'t retrieve image information. open_basedir restriction in place?<br />';
}
}
$this->log .= '- source variables<br />';
$this->log .= ' file_src_name : ' . $this->file_src_name . '<br />';
$this->log .= ' file_src_name_body : ' . $this->file_src_name_body . '<br />';
$this->log .= ' file_src_name_ext : ' . $this->file_src_name_ext . '<br />';
$this->log .= ' file_src_pathname : ' . $this->file_src_pathname . '<br />';
$this->log .= ' file_src_mime : ' . $this->file_src_mime . '<br />';
$this->log .= ' file_src_size : ' . $this->file_src_size . ' (max= ' . $this->file_max_size . ')<br />';
$this->log .= ' file_src_error : ' . $this->file_src_error . '<br />';
if ($this->file_is_image) {
$this->log .= '- source file is an image<br />';
$this->log .= ' image_src_x : ' . $this->image_src_x . '<br />';
$this->log .= ' image_src_y : ' . $this->image_src_y . '<br />';
$this->log .= ' image_src_pixels : ' . $this->image_src_pixels . '<br />';
$this->log .= ' image_src_type : ' . $this->image_src_type . '<br />';
$this->log .= ' image_src_bits : ' . $this->image_src_bits . '<br />';
}
}
/**
* Returns the version of GD
*
* @access public
* @param boolean $full Optional flag to get precise version
* @return float GD version
*/
function gdversion($full = false) {
static $gd_version = null;
static $gd_full_version = null;
if ($gd_version === null) {
if (function_exists('gd_info')) {
$gd = gd_info();
$gd = $gd["GD Version"];
$regex = "/([\d\.]+)/i";
} else {
ob_start();
phpinfo(8);
$gd = ob_get_contents();
ob_end_clean();
$regex = "/\bgd\s+version\b[^\d\n\r]+?([\d\.]+)/i";
}
if (preg_match($regex, $gd, $m)) {
$gd_full_version = (string) $m[1];
$gd_version = (float) $m[1];
} else {
$gd_full_version = 'none';
$gd_version = 0;
}
}
if ($full) {
return $gd_full_version;
} else {
return $gd_version;
}
}
/**
* Creates directories recursively
*
* @access private
* @param string $path Path to create
* @param integer $mode Optional permissions
* @return boolean Success
*/
function rmkdir($path, $mode = 0777) {
return is_dir($path) || ( $this->rmkdir(dirname($path), $mode) && $this->_mkdir($path, $mode) );
}
/**
* Creates directory
*
* @access private
* @param string $path Path to create
* @param integer $mode Optional permissions
* @return boolean Success
*/
function _mkdir($path, $mode = 0777) {
$old = umask(0);
$res = @mkdir($path, $mode);
umask($old);
return $res;
}
|