git-svn-id: https://192.168.0.254/svn/Proyectos.ClaveAudio_Web/trunk@6 44ade383-bb54-5b4f-835b-923f7702b206
127 lines
4.8 KiB
PHP
127 lines
4.8 KiB
PHP
<?php
|
|
require("_incl/upload.class.php");
|
|
|
|
function limpia($imagen){
|
|
if(file_exists($imagen)) {
|
|
unlink($imagen);
|
|
}
|
|
}
|
|
|
|
function uploadImagenProducto($prodID, $size1_w, $size1_h, $size2_w=0, $size2_h=0, $mascara='') {
|
|
$path = "../../_prds/"; // este directorio tiene que tener chmod 777
|
|
$upload_file_name = "prod_imagen"; // el nombre del campo tipo file de nuestro formulario
|
|
$acceptable_file_types = "image/gif|image/jpeg|image/pjpeg"; // acepta GIF et JPEG
|
|
$default_extension = "";
|
|
$mode = 1; // OPTIONS:
|
|
// 1 = overwrite mode
|
|
// 2 = create new with incremental extention
|
|
// 3 = do nothing if exists, highest protection
|
|
|
|
|
|
// un poco de limpieza previa
|
|
// este es el temporal
|
|
$glob = glob($path . $proid, '_tmp');
|
|
limpia($glob);
|
|
|
|
limpia($path . '_' . $size1_w . '.jpg');
|
|
limpia($path . '_' . $size2_w . '.jpg');
|
|
// fin de la limpia
|
|
|
|
if(strlen($_FILES['prod_imagen']['name'])) {
|
|
$my_uploader = new uploader('es'); // Create a new instance of the class
|
|
$my_uploader->max_filesize(150000); // OPTIONAL: set the max filesize of uploadable files in bytes
|
|
$my_uploader->max_image_size(1600, 1600); // OPTIONAL: if you're uploading images, you can set the max pixel dimensions
|
|
// UPLOAD the file
|
|
if ($my_uploader->upload($upload_file_name, $acceptable_file_types, $default_extension)) {
|
|
$my_uploader->save_file($path, $prodID . '_tmp', $mode);
|
|
if (!$my_uploader->error) {
|
|
$my_uploader->resize($prodID . '_' . $size1_w . '.jpg', $size1_w, $size1_h, 60);
|
|
if($size2_w) {
|
|
$my_uploader->resize($prodID . '_' . $size2_w . '.jpg', $size2_w, $size2_h, 60);
|
|
}
|
|
$my_uploader->delete_file;
|
|
}
|
|
}
|
|
if ($my_uploader->error) {
|
|
echo $my_uploader->error;
|
|
}
|
|
|
|
$glob = glob($path . $proid, '_tmp');
|
|
limpia($glob);
|
|
}
|
|
}
|
|
|
|
function uploadImagenOcasion($prodID, $size1_w, $size1_h, $size2_w=0, $size2_h=0, $mascara='') {
|
|
$path = "../../_ocs/"; // este directorio tiene que tener chmod 777
|
|
$upload_file_name = "prod_imagen"; // el nombre del campo tipo file de nuestro formulario
|
|
$acceptable_file_types = "image/gif|image/jpeg|image/pjpeg"; // acepta GIF et JPEG
|
|
$default_extension = "";
|
|
$mode = 1; // OPTIONS:
|
|
// 1 = overwrite mode
|
|
// 2 = create new with incremental extention
|
|
// 3 = do nothing if exists, highest protection
|
|
|
|
|
|
// un poco de limpieza previa
|
|
// este es el temporal
|
|
$glob = glob($path . $prodID. '_tmp');
|
|
limpia($glob);
|
|
|
|
limpia($path . '_' . $size1_w . '.jpg');
|
|
limpia($path . '_' . $size2_w . '.jpg');
|
|
// fin de la limpia
|
|
|
|
if(strlen($_FILES['prod_imagen']['name'])) {
|
|
$my_uploader = new uploader('es'); // Create a new instance of the class
|
|
$my_uploader->max_filesize(150000); // OPTIONAL: set the max filesize of uploadable files in bytes
|
|
$my_uploader->max_image_size(1600, 1600); // OPTIONAL: if you're uploading images, you can set the max pixel dimensions
|
|
// UPLOAD the file
|
|
if ($my_uploader->upload($upload_file_name, $acceptable_file_types, $default_extension)) {
|
|
$my_uploader->save_file($path, $prodID . '_tmp', $mode);
|
|
if (!$my_uploader->error) {
|
|
$my_uploader->resize($prodID . '_' . $size1_w . '.jpg', $size1_w, $size1_h, 60);
|
|
if($size2_w) {
|
|
$my_uploader->resize($prodID . '_' . $size2_w . '.jpg', $size2_w, $size2_h, 60);
|
|
}
|
|
$my_uploader->delete_file;
|
|
}
|
|
}
|
|
if ($my_uploader->error) {
|
|
echo $my_uploader->error;
|
|
}
|
|
|
|
$glob = glob($path . $proid. '_tmp');
|
|
limpia($glob);
|
|
}
|
|
}
|
|
|
|
function uploadImagenMarca($prodID, $size_w, $size_h, $mascara='') {
|
|
$path = "../../_logos/c/"; // este directorio tiene que tener chmod 777
|
|
$upload_file_name = "marca_imagen"; // el nombre del campo tipo file de nuestro formulario
|
|
$acceptable_file_types = "image/gif"; // acepta GIF et JPEG
|
|
$default_extension = "";
|
|
$mode = 1; // OPTIONS:
|
|
// 1 = overwrite mode
|
|
// 2 = create new with incremental extention
|
|
// 3 = do nothing if exists, highest protection
|
|
|
|
|
|
if(strlen($_FILES[$upload_file_name]['name'])) {
|
|
$my_uploader = new uploader('es'); // Create a new instance of the class
|
|
$my_uploader->max_filesize(150000); // OPTIONAL: set the max filesize of uploadable files in bytes
|
|
$my_uploader->max_image_size(1600, 1600); // OPTIONAL: if you're uploading images, you can set the max pixel dimensions
|
|
// UPLOAD the file
|
|
if ($my_uploader->upload($upload_file_name, $acceptable_file_types, $default_extension)) {
|
|
$my_uploader->save_file($path, $prodID . '.gif', $mode);
|
|
} else {
|
|
echo $my_uploader->error;
|
|
}
|
|
if ($my_uploader->error) {
|
|
echo $my_uploader->error;
|
|
}
|
|
} else {
|
|
echo 'no file';
|
|
}
|
|
}
|
|
|
|
?>
|