I have an interesting problem. I have a user profile form where he modifies data once he registers.
The whole folder where all the files that handle this modification of the profile data are, is called "profile" and has permission 0755 which is the default permission given by the hosting where I have contracted the service to host the page.
When I fill out the form, I pass the data by the post method by calling a page called "modify.php". There I do the whole recording process.
When I give the submit, I get error 403
<form class="ui form attached fluid segment" role="form" action="modificar.php" method="post" accept-charset="utf-8" autocomplete="off" enctype="multipart/form-data">
I have a htaccess that disables it to see the error correctly and it is actually a 403 error. I change the name of the destination page, and the same.
It does not happen to me with other pages of the project in which I also send photographs through the post.
Has anyone happened to this?
Can you give me a hand to see what I should check?
Thank you very much
the error it throws is specifically: link (X11; Linux x86_64) AppleWebKit / 537.36 (KHTML, like Gecko) Chrome / 62.0.3202.89 Safari / 537.36 / forms / profile / modify.php403
UPDATE INFORMATION:
When I go to modify.php it does a verification process of the google captcha. Then I execute the following. Process the image that I bring from the profile (if I enter a new photo)
$resultado = 0;
$usuario = $_POST['usuario'];
$idusuario = $_POST['idusuario'];
$nombreDestino = $idusuario . '.jpg';
//BASADO EN JPEG
if (isset($_FILES['fotoperfil']) && $_FILES['fotoperfil']['tmp_name']!=''){
//Imagen original
$old = getcwd(); // Conservo el directorio desde donde estoy accediendo
chdir('../../users/');
if (file_exists($nombreDestino)){
$do = unlink($nombreDestino);
clearstatcache();
if ($do != true) {
echo "hubo un error al intentar borrar el archivo";
}
} // Vuelvo al directorio donde estaba
$rtOriginal=$_FILES['fotoperfil']['tmp_name'];
$nombreDestino = $idusuario . '.jpg';
//Crear variable
$original = imagecreatefromjpeg($rtOriginal);
//Ancho y alto máximo
$max_ancho = 150; $max_alto = 150;
//Medir la imagen
list($ancho,$alto)=getimagesize($rtOriginal);
//Ratio
$x_ratio = $max_ancho / $ancho;
$y_ratio = $max_alto / $alto;
//Proporciones
if(($ancho <= $max_ancho) && ($alto <= $max_alto) ){
$ancho_final = $ancho;
$alto_final = $alto;
} else if (($x_ratio * $alto) < $max_alto){
$alto_final = ceil($x_ratio * $alto);
$ancho_final = $max_ancho;
} else {
$ancho_final = ceil($y_ratio * $ancho);
$alto_final = $max_alto;
}
//Crear un lienzo
$lienzo = imagecreatetruecolor($ancho_final,$alto_final);
//Copiar original en lienzo
imagecopyresampled($lienzo,$original,0,0,0,0,$ancho_final, $alto_final,$ancho,$alto);
//Destruir la original
imagedestroy($original);
//Crear la imagen y guardar en directorio upload/
imagejpeg($lienzo,"../../users/" . $nombreDestino);
}
I made some corrections in the code and now it works locally with the wamp but when I upload it to the server, it does not work. I'm still throwing error 403. Now I'm going to try removing all the part of the code where I do the deletion and the recording of the file to identify if that's where the problem is ... The error could be that the folder where I keep the images is called "USERS"? will it be a reserved name?