Ver Mensaje Individual
  #7 (permalink)  
Antiguo 15/05/2014, 15:20
sahe_lizzy
 
Fecha de Ingreso: noviembre-2013
Ubicación: México
Mensajes: 22
Antigüedad: 10 años, 5 meses
Puntos: 0
Respuesta: relacion de tablas

<?php
include("../../Connections/conexion.php");
error_reporting (E_ALL ^ E_NOTICE);
session_start(); //Do not remove this
//only assign a new timestamp if the session variable is empty
if (!isset($_SESSION['random_key']) || strlen($_SESSION['random_key'])==0){
$_SESSION['random_key'] = strtotime(date('Y-m-d H:i:s')); //asigna la fecha y la hora a la variable de sesion
$_SESSION['user_file_ext']= "";
}
$upload_dir = "imagenes_cortadas"; // The directory for the images to be saved in
$upload_path = $upload_dir."/"; // The path to where the image will be saved
$large_image_prefix = "original_"; // The prefix name to large image
$thumb_image_prefix = "cortada_"; // The prefix name to the thumb image
$large_image_name = $large_image_prefix.$_SESSION['random_key']; // New name of the large image (append the timestamp to the filename)
$thumb_image_name = $thumb_image_prefix.$_SESSION['random_key']; // New name of the thumbnail image (append the timestamp to the filename)
$max_file = "10"; // Maximum file size in MB
$max_width = "500"; // Max width allowed for the large image
$thumb_width = "410"; // Width of thumbnail image
$thumb_height = "200"; // Height of thumbnail image
// Only one of these image types should be allowed for upload
$allowed_image_types = array('image/pjpeg'=>"jpg",'image/jpeg'=>"jpg",'image/jpg'=>"jpg",'image/png'=>"png",'image/x-png'=>"png",'image/gif'=>"gif");
$allowed_image_ext = array_unique($allowed_image_types); // do not change this
$image_ext = ""; // initialise variable, do not change this.
foreach ($allowed_image_ext as $mime_type => $ext) {
$image_ext.= strtoupper($ext)." ";//covierte a mayusculas strtoupper
}

function resizeImage($image,$width,$height,$scale) {
list($imagewidth, $imageheight, $imageType) = getimagesize($image);
$imageType = image_type_to_mime_type($imageType);
$newImageWidth = ceil($width * $scale);
$newImageHeight = ceil($height * $scale);
$newImage = imagecreatetruecolor($newImageWidth,$newImageHeigh t);
switch($imageType) {
case "image/gif":
$source=imagecreatefromgif($image);
break;
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
$source=imagecreatefromjpeg($image);
break;
case "image/png":
case "image/x-png":
$source=imagecreatefrompng($image);
break;
}
imagecopyresampled($newImage,$source,0,0,0,0,$newI mageWidth,$newImageHeight,$width,$height);

switch($imageType) {
case "image/gif":
imagegif($newImage,$image);
break;
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
imagejpeg($newImage,$image,90);
break;
case "image/png":
case "image/x-png":
imagepng($newImage,$image);
break;
}

chmod($image, 0777);
return $image;

}

function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale){
list($imagewidth, $imageheight, $imageType) = getimagesize($image);
$imageType = image_type_to_mime_type($imageType);

$newImageWidth = ceil($width * $scale);
$newImageHeight = ceil($height * $scale);
$newImage = imagecreatetruecolor($newImageWidth,$newImageHeigh t);
switch($imageType) {
case "image/gif":
$source=imagecreatefromgif($image);
break;
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
$source=imagecreatefromjpeg($image);
break;
case "image/png":
case "image/x-png":
$source=imagecreatefrompng($image);
break;
}
imagecopyresampled($newImage,$source,0,0,$start_wi dth,$start_height,$newImageWidth,$newImageHeight,$ width,$height);//copia una porción rectangular de una imagen a otra imagen, la interpolación de valores de píxel sin problemas de manera que, en particular, reducir el tamaño de una imagen todavía conserva una gran cantidad de la claridad.
switch($imageType) {
case "image/gif":
imagegif($newImage,$thumb_image_name);
break;
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
imagejpeg($newImage,$thumb_image_name,90);
break;
case "image/png":
case "image/x-png":
imagepng($newImage,$thumb_image_name);
break;
}
chmod($thumb_image_name, 0777);
return $thumb_image_name;
}

function getHeight($image) {
$size = getimagesize($image);
$height = $size[1];
return $height;
}

function getWidth($image) {
$size = getimagesize($image);
$width = $size[0];
return $width;
}
//Image Locations
$large_image_location = $upload_path.$large_image_name.$_SESSION['user_file_ext'];
$thumb_image_location = $upload_path.$thumb_image_name.$_SESSION['user_file_ext'];

//Create the upload directory with the right permissions if it doesn't exist
if(!is_dir($upload_dir)){
mkdir($upload_dir, 0777);
chmod($upload_dir, 0777);
}

//Check to see if any images with the same name already exist
if (file_exists($large_image_location)){
if(file_exists($thumb_image_location)){
//include("imagenes_cortadas.php");


ESTO VA ANTES DE LO QUE ACABO DE POSTEAR