Este es el codigo
Código PHP:
<?php
include("conexion.php");
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["img_profile"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["img_profile"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
//if ($_FILES["fileToUpload"]["size"] > 80000000) {
//echo "Sorry, your file is too large.";
//$uploadOk = 0;
//}
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
///echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
$uploadOk = 0;
}
// Check file size
if (move_uploaded_file($_FILES["img_profile"]["tmp_name"], $target_file)) {
//echo "El archivo ". basename( $_FILES["foto_1"]["name"]). " ha sido cargado.";
} else {
//echo "Sorry, there was an error uploading your file.";
}
$sql = "update login set nombre = '".$_POST["nombre"]."', username = '".$_POST["username"]."', email = '".$_POST["email"]."', password = '".$_POST["password"]."', celphone = '".$_POST["celphone"]."', img_profile = '".$_POST["$target_file"]."' where cod_us='".$_POST["cod_us"]."'";
$res=mysql_query($sql,$conexion);
echo "<script type=''>
alert('Perfil Modificado correctamente, debes cerrar sesion para ver los cambios');
window.location='profile.php?cod_us=".$_POST["cod_us"]."';
</script>";
?>