0

When i charge the image this sees flipped but is only with some ones, and all was uploaded with the dropzone, I have a form that serves only to upload the image by dragging, only one photo is allowed to be uploaded since it is used for the profile picture of each birthday boy, then the photo is uploaded and the program is directed to the driver which validates the fields and then create a folder with the id of the user if it does not exist and finally save the image using the user's id as the name and thus replace the previous photo, but with certain photos it is flipped over and the reason is not, and in the database the name of the photo and its extension are stored.

The form that shows the photo is loaded by another driver that loads the photo and the information of the user and then by means of a jquery the view is filled with the information that was obtained.

At this time, you already insert the image and store the name in the database, but when you load it, you see it with a 90 degree turn


<!--View-->


 <?php
    $link = mysqli_connect("localhost", "pruebas", "xxxx");
    mysqli_select_db($link, "colitali_iqpantallas");
    $tildes = $link->query("SET NAMES 'utf8'"); //Para que se muestren las tildes correctamente
    $result = mysqli_query($link, "SELECT * FROM birthdays ORDER BY id");
    $estado ="active";
    $contador=0;
    $delete="";
?>
    <div class="alert alert-dismissible" role="alert" style="display: none;">
    </div>
    <table id="tableBirthdays" class="table display">
        <thead>
            <tr>
                <th scope="col">#</th>
                <th scope="col">Nombre</th>
                <th scope="col">Apellido</th>
                <th scope="col">Cargo</th>
                <th scope="col">Fecha de Nacimiento</th>
                <th scope="col">Inicio del cargo</th>
                <th scope="col">Imagen</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>Id</th>
                <th>Nombre</th>
                <th>Apellido</th>
                <th>Cargo</th>
                <th>Fecha de Nacimiento</th>
                <th>Inicio del cargo</th>
                <th>Imagen</th>
            </tr>
        </tfoot>
        <tbody class="contentTable">


<?php
    while ($fila = mysqli_fetch_array($result)){
        $estado="";
        $col_name=$fila['name'];
        $col_surname=$fila['surname'];
        $col_job=$fila['job'];
        $col_id=$fila['id']; 
        $col_start=$fila['start'];
        $col_cumple=$fila['day']."/".$fila['month']."/".$fila['year'];
        $col_image=($fila['image']==NULL) ? "default.png" : $col_id."/".$fila['image'] ;
        $delete .= '<option class="opcionBirthdays" data-src="birthday" value="'.$col_id.'" title="'.$col_name." ".$col_surname.'">';
        $delete .= $col_id.". ";
        $delete .= $col_name." ".$col_surname;
        $delete .= '</option>';
?>
            <tr>
                <td>
                    <label><?php echo $col_id; ?></label>
                </td>
                <td>
                    <div class="col">
                        <div class="row">
                            <input class="form-control" type="text" name="name" value="<?php echo $col_name; ?>" width="150" id="birthdaysName-<?php echo $col_id; ?>" required/>
                            <label class="d-none"><?php echo $col_name; ?></label>
                        </div>
                        <div class="row">
                            <button type="button" value="Guardar" name="detail" class="botonIQ btnGuardar" data-action='controller/uploadBirthday.php?tipo=1&code=<?php echo $col_id; ?>'>Guardar</button>
                        </div>
                    </div>
                </td>
                <td>
                    <div class="col">
                        <div class="row">
                            <input class="form-control" type="text" name="surname" value="<?php echo $col_surname; ?>" width="150" id="birthdaysSurname-<?php echo $col_id; ?>" required/>
                            <label class="d-none"><?php echo $col_surname; ?></label>
                        </div>
                        <div class="row">
                            <button type="button" value="Guardar" name="detail" class="botonIQ btn-xs btnGuardar" data-action='controller/uploadBirthday.php?tipo=2&code=<?php echo $col_id; ?>'>Guardar</button>
                        </div>
                    </div>
                </td>
                <td>
                    <div class="col">
                        <div class="row">
                            <input class="form-control" type="text" name="job" value="<?php echo $col_job; ?>" width="150" id="birthdaysJob-<?php echo $col_id; ?>"required/>
                            <label class="d-none"><?php echo $col_job; ?></label>
                        </div>
                        <div class="row">
                            <button type="button" value="Guardar" name="detail" class="botonIQ btnGuardar" data-action='controller/uploadBirthday.php?tipo=3&code=<?php echo $col_id; ?>'>Guardar</button>
                        </div>
                    </div>
                </td>
                <td>
                    <div class="col">
                        <div class="row">
                            <input id="birthdaysBirthday-<?php echo $col_id; ?>" class="datepicker form-control" data-elemento="birthdays" width="150" value="<?php echo $col_cumple; ?>" name="birthday" readonly required/>
                            <label class="d-none"><?php echo $col_cumple; ?></label>
                        </div>
                        <div class="row">
                            <button type="button" value="Guardar" name="detail" class="botonIQ btn-xs btnGuardar" data-action='controller/uploadBirthday.php?tipo=4&code=<?php echo $col_id; ?>'>Guardar</button>
                        </div>
                    </div>
                </td>
                <td>
                    <div class="col">
                        <div class="row">
                            <input id="birthdaysStart-<?php echo $col_id; ?>" class="datepicker form-control" data-elemento="birthdays" width="150" value="<?php echo $col_start; ?>" name="start" readonly required/>
                            <label class="d-none"><?php echo $col_start; ?></label>
                        </div>
                        <div class="row">
                            <button type="button" value="Guardar" name="detail" class="botonIQ btnGuardar" data-action='controller/uploadBirthday.php?tipo=5&code=<?php echo $col_id; ?>'>Guardar</button>
                        </div>
                    </div>
                </td>
                <td>
                    <form action='controller/uploadBirthday.php?tipo=6&code=<?php echo $col_id; ?>' class='dropzone' data-elemento="birthdays" enctype='multipart/form-data' id='birthdaysImage-<?php echo $col_id; ?>' style="height: 150px; width: 100px; font-size: 10px">
                        <img class='img-l miniImagen' width="40px" height="40px" src='images/<?php echo $col_image; ?>' />
                    </form>
                </td>
            </tr>
<?php
        $contador++;
    } 
?> 







<!-- Controller --> 

<?php
    include_once "con.php";
    switch ($_GET['tipo']) {
        case 1:
        //Modificar el nombre //error

        break;
        case 2:
        //Modificar el apellido

        break;
        case 3:
        //Modificar el cargo

        break;
        case 4:
        //Modificar la fecha de nacimiento

        break;
        case 5:
        //Modificar la fecha en la que empezo a trabjar

        break;
        case 6:
        //Modificar la imagen
            if (isset($_GET['code'])) {
                $id=$_GET['code'];
                if (!file_exists('../images/'.$id)) {
                    $oldmask = umask(0);
                    mkdir('../images/'.$id, 0777);
                    umask($oldmask);
                }
                if($fila['image']!=NULL) {
                    unlink('../images/'.$id."/".$id.'.png');
                }
                $ds = DIRECTORY_SEPARATOR;
                $storeFolder = '../images/'.$id;
                if (!empty($_FILES)) {

                    $tempFile = $_FILES['file']['tmp_name'];             
                    $targetPath = dirname( __FILE__ ) . $ds. $storeFolder . $ds;
                    $targetFile =  $targetPath.$id. ".png";
                    move_uploaded_file($tempFile,$targetFile); 
                    $con->query("SET NAMES 'utf8'");
                    $sentencia = $con->prepare("UPDATE birthdays SET image = ? WHERE id = ?;");
                    $resultado = $sentencia->execute([$id.'.png', $id]);
                }
                else {
                    die("No se a subido nada");
                }

            }
            else {
                    die("No se a recibido nada");
            }
        break;
    }
    include_once "bitacora.php";
    header('Location: ../home.php?forms=birthdays');

?> ```

The image should look right, that is to say as it was taken with the cell phone or the camera, but it is seen flipped


[!look the this image, this is the visual of the problem][1]][1]


  [1]: https://i.stack.imgur.com/zMg6A.png
Andrés Vélez
  • 113
  • 1
  • 6
  • So in reality, you're saying that the image that was uploaded by the user is 90 degrees off? You don't seem to do any image manipulation in the code provided, so I'm not really sure what you're asking. – Jonnix Jan 21 '19 at 15:40
  • @JonStirling How can I upload images to my question? I do not get what I used to upload images – Andrés Vélez Jan 21 '19 at 15:42
  • Are you sure these are `png` images? That does not sound like the typical output of a phone or camera and the problem you describe, sounds a lot like an exif rotation in a `jpeg` file, see https://stackoverflow.com/a/45963569/42139 – jeroen Jan 21 '19 at 15:44
  • @jeroen Yes, I just inspected the image and it's in PNG – Andrés Vélez Jan 21 '19 at 15:48
  • A friend told me that this problem is for images take in a cell phone camera but we don't know how to fixed – Andrés Vélez Jan 21 '19 at 15:51
  • Possible duplicate of [PHP read\_exif\_data and Adjust Orientation](https://stackoverflow.com/questions/7489742/php-read-exif-data-and-adjust-orientation) –  Jan 21 '19 at 15:56
  • This is a demo that I just made http://seadoglabs.com/iq/pru/home.php look id 22 – Andrés Vélez Jan 21 '19 at 16:00
  • @Maurice I read that, but I do not understand how to implement this with my code – Andrés Vélez Jan 21 '19 at 16:04

0 Answers0