![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
16/02/2008, 23:44
|
![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:
$this->translation['file_too_big'] = 'File too big.';
$this->translation['no_mime'] = 'MIME type can\'t be detected.';
$this->translation['incorrect_file'] = 'Incorrect type of file.';
$this->translation['image_too_wide'] = 'Image too wide.';
$this->translation['image_too_narrow'] = 'Image too narrow.';
$this->translation['image_too_high'] = 'Image too high.';
$this->translation['image_too_short'] = 'Image too short.';
$this->translation['ratio_too_high'] = 'Image ratio too high (image too wide).';
$this->translation['ratio_too_low'] = 'Image ratio too low (image too high).';
$this->translation['too_many_pixels'] = 'Image has too many pixels.';
$this->translation['not_enough_pixels'] = 'Image has not enough pixels.';
$this->translation['file_not_uploaded'] = 'File not uploaded. Can\'t carry on a process.';
$this->translation['already_exists'] = '%s already exists. Please change the file name.';
$this->translation['temp_file_missing'] = 'No correct temp source file. Can\'t carry on a process.';
$this->translation['source_missing'] = 'No correct uploaded source file. Can\'t carry on a process.';
$this->translation['destination_dir'] = 'Destination directory can\'t be created. Can\'t carry on a process.';
$this->translation['destination_dir_missing'] = 'Destination directory doesn\'t exist. Can\'t carry on a process.';
$this->translation['destination_path_not_dir'] = 'Destination path is not a directory. Can\'t carry on a process.';
$this->translation['destination_dir_write'] = 'Destination directory can\'t be made writeable. Can\'t carry on a process.';
$this->translation['destination_path_write'] = 'Destination path is not a writeable. Can\'t carry on a process.';
$this->translation['temp_file'] = 'Can\'t create the temporary file. Can\'t carry on a process.';
$this->translation['source_not_readable'] = 'Source file is not readable. Can\'t carry on a process.';
$this->translation['no_create_support'] = 'No create from %s support.';
$this->translation['create_error'] = 'Error in creating %s image from source.';
$this->translation['source_invalid'] = 'Can\'t read image source. Not an image?.';
$this->translation['gd_missing'] = 'GD doesn\'t seem to be present.';
$this->translation['watermark_no_create_support'] = 'No create from %s support, can\'t read watermark.';
$this->translation['watermark_create_error'] = 'No %s read support, can\'t create watermark.';
$this->translation['watermark_invalid'] = 'Unknown image format, can\'t read watermark.';
$this->translation['file_create'] = 'No %s create support.';
$this->translation['no_conversion_type'] = 'No conversion type defined.';
$this->translation['copy_failed'] = 'Error copying file on the server. copy() failed.';
$this->translation['reading_failed'] = 'Error reading the file.';
// determines the language
$this->lang = $lang;
if ($this->lang != 'en_GB' && file_exists('lang/class.upload.' . $lang . '.php')) {
$translation = null;
include('lang/class.upload.' . $lang . '.php');
if (is_array($translation)) {
$this->translation = array_merge($this->translation, $translation);
} else {
$this->lang = 'en_GB';
}
}
// determines the supported MIME types, and matching image format
$this->image_supported = array();
if ($this->gdversion()) {
if (imagetypes() & IMG_GIF) {
$this->image_supported['image/gif'] = 'gif';
}
if (imagetypes() & IMG_JPG) {
$this->image_supported['image/jpg'] = 'jpg';
$this->image_supported['image/jpeg'] = 'jpg';
$this->image_supported['image/pjpeg'] = 'jpg';
}
if (imagetypes() & IMG_PNG) {
$this->image_supported['image/png'] = 'png';
$this->image_supported['image/x-png'] = 'png';
}
if (imagetypes() & IMG_WBMP) {
$this->image_supported['image/bmp'] = 'bmp';
$this->image_supported['image/x-ms-bmp'] = 'bmp';
$this->image_supported['image/x-windows-bmp'] = 'bmp';
}
}
// display some system information
if (empty($this->log)) {
$this->log .= '<b>system information</b><br />';
$inis = ini_get_all();
$open_basedir = (array_key_exists('open_basedir', $inis) && array_key_exists('local_value', $inis['open_basedir']) && !empty($inis['open_basedir']['local_value'])) ? $inis['open_basedir']['local_value'] : false;
$gd = $this->gdversion() ? $this->gdversion(true) : 'GD not present';
$supported = trim((in_array('png', $this->image_supported) ? 'png' : '') . ' ' . (in_array('jpg', $this->image_supported) ? 'jpg' : '') . ' ' . (in_array('gif', $this->image_supported) ? 'gif' : '') . ' ' . (in_array('bmp', $this->image_supported) ? 'bmp' : ''));
$this->log .= '- GD version : ' . $gd . '<br />';
$this->log .= '- supported image types : ' . (!empty($supported) ? $supported : 'none') . '<br />';
$this->log .= '- open_basedir : ' . (!empty($open_basedir) ? $open_basedir : 'no restriction') . '<br />';
$this->log .= '- language : ' . $this->lang . '<br />';
}
if (!$file) {
$this->uploaded = false;
$this->error = $this->translate('file_error');
}
// check if we sent a local filename rather than a $_FILE element
if (!is_array($file)) {
if (empty($file)) {
$this->uploaded = false;
$this->error = $this->translate('file_error');
} else {
$this->no_upload_check = TRUE;
// this is a local filename, i.e.not uploaded
$this->log .= '<b>' . $this->translate("source is a local file") . ' ' . $file . '</b><br />';
if ($this->uploaded && !file_exists($file)) {
$this->uploaded = false;
$this->error = $this->translate('local_file_missing');
}
if ($this->uploaded && !is_readable($file)) {
$this->uploaded = false;
$this->error = $this->translate('local_file_not_readable');
}
if ($this->uploaded) {
$this->file_src_pathname = $file;
$this->file_src_name = basename($file);
$this->log .= '- local 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_exists($file) ? filesize($file) : 0);
// we try to retrieve the MIME type
$info = getimagesize($this->file_src_pathname);
$this->file_src_mime = (is_array($info) && array_key_exists('mime', $info) ? $info['mime'] : null);
// if we don't have a MIME type, we attempt to retrieve it the old way
if (empty($this->file_src_mime)) {
$mime = (is_array($info) && array_key_exists(2, $info) ? $info[2] : null); // 1 = GIF, 2 = JPG, 3 = PNG
$this->file_src_mime = ($mime==IMAGETYPE_GIF ? 'image/gif' : ($mime==IMAGETYPE_JPEG ? 'image/jpeg' : ($mime==IMAGETYPE_PNG ? 'image/png' : ($mime==IMAGETYPE_BMP ? 'image/bmp' : null))));
}
// if we still don't have a MIME type, we attempt to retrieve it otherwise
if (empty($this->file_src_mime) && function_exists('mime_content_type')) {
$this->file_src_mime = mime_content_type($this->file_src_pathname);
}
$this->file_src_error = 0;
// determine whether the file is an image
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];
}
}
}
|