Foros del Web » Programando para Internet » PHP »

PHP OO Ayuda Porfavor

Estas en el tema de Ayuda Porfavor en el foro de PHP en Foros del Web. Resulta que tengo un archivo llamado avatar-upload.php en el cual pues configuro la imagen que el usuario quiera subir de su avatar pero al querer ...
  #1 (permalink)  
Antiguo 27/02/2011, 15:19
 
Fecha de Ingreso: octubre-2009
Mensajes: 7
Antigüedad: 14 años, 7 meses
Puntos: 0
Pregunta Ayuda Porfavor

Resulta que tengo un archivo llamado avatar-upload.php en el cual pues configuro la imagen que el usuario quiera subir de su avatar pero al querer hacerlo me marca este error alguien sabria decirme o explicarme porque

Error:

<br>
<b>Warning</b>: move_uploaded_file(/avatares/tmp/3b15be84aff20b322a93c0b9aaa62e25ad33b4b4.jpg) [<a href="function.move-uploaded-file">function.move-uploaded-file</a>]: failed to open stream: No such file or directory in <b>/home/muyfa976/public_html/NewSoftx/avatar-upload.php</b> on line <b>84</b><br>
<br>
<b>Warning</b>: move_uploaded_file() [<a href="function.move-uploaded-file">function.move-uploaded-file</a>]: Unable to move '/tmp/phpewJMTJ' to '/avatares/tmp/3b15be84aff20b322a93c0b9aaa62e25ad33b4b4.jpg' in <b>/home/muyfa976/public_html/NewSoftx/avatar-upload.php</b> on line <b>84</b><br>
{"error":"No se pudo subir el archivo"}
Error: error
  #2 (permalink)  
Antiguo 27/02/2011, 15:22
 
Fecha de Ingreso: octubre-2009
Mensajes: 245
Antigüedad: 14 años, 6 meses
Puntos: 17
Respuesta: Ayuda Porfavor

El error te esta indicando que no existe el directorio o el archivo, verifica los permisos del directorio destino
__________________
Saludos.
  #3 (permalink)  
Antiguo 27/02/2011, 15:23
 
Fecha de Ingreso: noviembre-2009
Mensajes: 535
Antigüedad: 14 años, 5 meses
Puntos: 25
Respuesta: Ayuda Porfavor

como dice el error no hay el archivo en el directorio
__________________
cada vez que aprendes algo te crees que no sabes nada
  #4 (permalink)  
Antiguo 27/02/2011, 15:24
 
Fecha de Ingreso: octubre-2009
Mensajes: 7
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: Ayuda Porfavor

y cual deveria ser el permiso o los permisos de la carpeta destino por que al final se esta subiendo a una carpeta
  #5 (permalink)  
Antiguo 27/02/2011, 15:26
 
Fecha de Ingreso: octubre-2009
Mensajes: 7
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: Ayuda Porfavor

esto es el archivo php
Cita:
<?php
session_start();
include('configuracion.php');
include('funciones.php');
function jerror($e){die('{"error":"'.$e.'"}');}
if(!isLogged()) { jerror('Debes logearte'); }
if($_GET['save']) {
if(!$_SESSION['avurl']) { jerror('No has subido ning&uacute;n avatar'); }
$ex = explode('.', $_SESSION['avurl']);
switch($ex[(count($ex)-1)]) {
case 'gif':
$im = imagecreatefromgif($_SESSION['avurl']);
break;
case 'png':
$im = imagecreatefrompng($_SESSION['avurl']);
break;
case 'jpg':
case 'jpeg':
$im = imagecreatefromjpeg($_SESSION['avurl']);
break;
}
list($fx, $fy, $sx, $sy) = explode(',', $_GET['coords']);
if(!ctype_digit($fx) || $fx > imagesx($im)) { jerror('Las coordenadas no son correctas'); }
if(!ctype_digit($fy) || $fy > imagesy($im)) { jerror('Las coordenadas no son correctas'); }
if(!ctype_digit($sx) || $sx > imagesx($im)) { jerror('Las coordenadas no son correctas'); }
if(!ctype_digit($sy) || $sy > imagesy($im)) { jerror('Las coordenadas no son correctas'); }
if($fx > $sx) { $c = $fx; $fx = $sx; $sx = $c; unset($c); }
if($fy > $sy) { $c = $fy; $fy = $sy; $sy = $c; unset($c); }
$w = $sx-$fx;
$h = $sy-$fy;
$img = imagecreatetruecolor($w, $h);
imagecopyresampled($img, $im, 0, 0, $fx, $fy, $w, $h, $w, $h);
if(mysql_num_rows($q = mysql_query("SELECT id, url FROM `avatares` WHERE user = '".$currentuser['id']."'"))) {
$a = mysql_fetch_row($q);
unlink($a[1]);
mysql_query("DELETE FROM `avatares` WHERE id = '".$a[0]."'");
mysql_query("UPDATE `users` SET avatar = '0.gif', percent = percent-2.5 WHERE id = '".$currentuser['id']."'");
}
mysql_query("INSERT INTO `avatares` (user) VALUES ('".$currentuser['id']."')");
unlink($_SESSION['avurl']);
switch($ex[(count($ex)-1)]) {
case 'gif':
$i = mysql_insert_id().'.gif';
$url = '/avatares/120/'.$i;
imagegif($img, $url);
break;
case 'png':
$i = mysql_insert_id().'.png';
$url = '/avatares/120/'.$i;
imagepng($img, $url);
break;
case 'jpg':
case 'jpeg':
$i = mysql_insert_id().'.jpg';
$url = '/avatares/120/'.$i;
imagejpeg($img, $url);
break;
}
mysql_query("UPDATE `avatares` SET url = '".$url."', img = '".$i."' WHERE id = '".mysql_insert_id()."'");
mysql_query("UPDATE `users` SET avatar = '".$i."', percent = percent+2.5 WHERE id = '".$currentuser['id']."'");
imagedestroy($im);
imagedestroy($img);
} elseif($_POST['del']) {
if(!$_SESSION['avurl']) { jerror('No has subido ning&uacute;n avatar'); }
unlink($_SESSION['avurl']);
$q = mysql_query("SELECT img FROM `avatares` WHERE user = '".$currentuser['id']."'");
if(!mysql_num_rows($q)) {
die('/avatares/120/0.gif');
} else {
$a = mysql_fetch_row($q);
die('/avatares/120/'.$a[0]);
}
} else {
if(!$_FILES['file-avatar']) { jerror('No has enviado datos'); }
if(!$_POST['maxw'] || !$_POST['maxh'] || !ctype_digit($_POST['maxw']) || !ctype_digit($_POST['maxh'])) { jerror('Datos incompletos o incorrectos'); }
$maxw = $_POST['maxw']-300;
$maxh = $_POST['maxh']-120;
$maxsize = 2097152;
$allowed = array('image/gif', 'image/jpeg', 'image/png', 'image/pjpeg');
if($_FILES['file-avatar']['size'] > $maxsize) { jerror('El archivo es demasiado pesado >'.$_FILES['file-avatar']['size']); }
if(!in_array($_FILES['file-avatar']['type'], $allowed)) { jerror('El archivo no es una imagen v&aacute;lida'); }
$dest = '/avatares/tmp/'.sha1_file($_FILES['file-avatar']['tmp_name']).strtolower(substr($_FILES['file-avatar']['name'], strrpos($_FILES['file-avatar']['name'], '.')));
list($width, $height) = getimagesize($_FILES['file-avatar']['tmp_name']);
if(!move_uploaded_file($_FILES['file-avatar']['tmp_name'], $dest)) {
jerror('No se pudo subir el archivo');
} else {
$orurl = substr($dest, 2);
$dest = $_SERVER['DOCUMENT_ROOT'].substr($dest, 2);
$_SESSION['avurl'] = $dest;
if($width > $maxw || $height > $maxh) {
if(($width-$maxw) > ($height-$maxh)) {//jerror("$maxw<$maxh<1");
$minusw = ($width-$maxw);
$percent = ($minusw/$width)*100;
$minush = $height/100*$percent;
} elseif(($width-$maxw) < ($height-$maxh)) { //jerror("$maxw<$maxh<2");
$minush = ($height-$maxh);
$percent = ($minush/$height)*100;
$minusw = $width/100*$percent;
} else { //jerror("$maxw<$maxh<3");
$minusw = $minush = $width-$maxw;
}
$nwidth = $width-$minusw;
$nheight = $height-$minush;
$ex = explode('.', $dest);
switch($ex[(count($ex)-1)]) {
case 'gif':
$im = imagecreatefromgif($dest);
break;
case 'png':
$im = imagecreatefrompng($dest);
break;
case 'jpg':
case 'jpeg':
$im = imagecreatefromjpeg($dest);
break;
}
$img = imagecreatetruecolor($nwidth, $nheight);
imagecopyresampled($img, $im, 0, 0, 0, 0, $nwidth, $nheight, imagesx($im), imagesy($im));
switch($ex[(count($ex)-1)]) {
case 'gif':
imagegif($img, $dest);
break;
case 'png':
imagepng($img, $dest);
break;
case 'jpg':
case 'jpeg':
imagejpeg($img, $dest);
break;
}
imagedestroy($im);
imagedestroy($img);
}
die('{"msg":"'.$orurl.'"}');
}
}
?>
  #6 (permalink)  
Antiguo 27/02/2011, 15:41
marcofbb
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Ayuda Porfavor

También tenes otro error en:
Warning: Cannot modify header information - headers already sent by (output started at /home/muyfa976/public_html/NewSoftx/index.php:25) in /home/muyfa976/public_html/NewSoftx/paginas/confirmemail.php on line 9
  #7 (permalink)  
Antiguo 27/02/2011, 15:46
 
Fecha de Ingreso: octubre-2009
Mensajes: 7
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: Ayuda Porfavor

Cita:
Iniciado por marcofbb Ver Mensaje
También tenes otro error en:
Warning: Cannot modify header information - headers already sent by (output started at /home/muyfa976/public_html/NewSoftx/index.php:25) in /home/muyfa976/public_html/NewSoftx/paginas/confirmemail.php on line 9
y cual es el error ay :S
  #8 (permalink)  
Antiguo 27/02/2011, 16:18
marcofbb
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Ayuda Porfavor

Parece que pusiste una cabecera header despues de contenido :S

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:02.