Ver Mensaje Individual
  #4 (permalink)  
Antiguo 29/07/2008, 14:27
miguev
 
Fecha de Ingreso: julio-2008
Mensajes: 5
Antigüedad: 15 años, 9 meses
Puntos: 0
Respuesta: Problema con Upload CHMOD 777

Revisando el código he encontrado los chmod a la hora de crear las galerias, he intentado integrarlo en el php del upload (básicamente haciendo copy&paste :) ) pero no me ha funcionado nada.

Este es el código de los chmod de las entradas de nuevas galerias

Código:
//make new folder and chmod it
mkdir(realpath("../") . '/' . $new_folder, 0777);

//chmod again just to make sure
chmod(realpath("../") . '/' . $new_folder, 0777);

//also make the thumbs folder for this gallery
mkdir(realpath("../") . '/' . $new_folder . '/thumbs', 0777);

//chmod again just to make sure
chmod(realpath("../") . '/' . $new_folder . '/thumbs', 0777);

y este es el codigo doonde yo creo que debería de especificarse el chmode, pero no estoy para nada seguro.

Código:
//upload pictures
for($x=1; $x<=5; $x++){
	if ($_FILES["file$x"]["size"] > 0) {
		//temp location
		$imgSource = $_FILES["file$x"]["tmp_name"];
		
		//path to gallery folder
		$dir = realpath("../$folder");
		//picture dir vars
		$pic = urldecode(basename($_FILES["file$x"]["name"]));
		//convert spaces to underscores
		$pic = str_replace(" ", "_", $pic);
		//move file 
		
		if(move_uploaded_file( $imgSource, "$dir/$pic")){
			list($width, $height, $type, $attr) = getimagesize("$dir/$pic");
			//get ratio of width/height
			$ratio = round($width/$height, 2);
			
			if ($process == "crop"){
				//determine the width and height to keep the thumbnail uniform
				//then crop the thumbnail in the center to get our new thumbnail
				if($ratio > $thumb_ratio){
					//picture is too wide so we will need to crop the thumbnails width
					$new_width = ceil(($width*$thumb_width)/$height);
					$new_height = $thumb_height;
					$crop_x = (round($new_width/2))-(round($thumb_width/2));
					$crop_y = 0;
				} elseif($ratio < $thumb_ratio){
					//picture is too high so we will need to crop the thumbnails height
					$new_width = $thumb_width;
					$new_height = ceil(($height*$thumb_height)/$width);
					$crop_x = 0;
					$crop_y = (round($new_height/2))-(round($thumb_height/2));
				} else {
					//the ratio of the image is the same as the thumbnail
					$new_width = $thumb_width;
					$new_height = $thumb_height;
					$crop_x = 0;
					$crop_y = 0;
				}
				
				//time to resize the image and crop it for thumbnail
				$imageEditor = new ImageEditor($pic, $dir . "/");
				//resize
				$imageEditor->resize($new_width, $new_height);
				//crop
				$imageEditor->crop($crop_x, $crop_y, $thumb_width, $thumb_height);
				//save
				$imageEditor->outputFile($pic, $dir . "/thumbs/");
			} else { //make a basic thumbnail
				if($ratio > $thumb_ratio){
					//picture is too wide so we will set the the width to its maximum
					$new_width = $thumb_width;
					$new_height = ceil(($thumb_width*$height)/$width);
				} elseif($ratio < $thumb_ratio){
					//picture is too high so we will set the height to its maximum
					$new_width = ceil(($thumb_height*$width)/$height);
					$new_height = $thumb_height;
				} else {
					//the ratio of the image is the same as the thumbnail
					$new_width = $thumb_width;
					$new_height = $thumb_height;
				}
				
				//time to resize the image and crop it for thumbnail
				$imageEditor = new ImageEditor($pic, $dir . "/");
				//resize
				$imageEditor->resize($new_width, $new_height);
				//save
				$imageEditor->outputFile($pic, $dir . "/thumbs/");
			}
			//create xml for this picture
			$pics_xml_add .= "\t<image location=\"" . $pic . "\" desc=\"" . stripslashes($_POST["desc$x"]) . "\" />\n";
		}
	}
}

Alguna sugerencia de como poner el mismo de los nombres de la galería para los archivos que se suben???

Siento insitir tanto pero es que es lo último que me falta para terminar una web para un cliente y ya tengo ganas de ponerme con otro proyecto.

Gracias y un saludo.