S
S
sputnickk2020-09-08 08:32:28
iPhone
sputnickk, 2020-09-08 08:32:28

Why are images not loading on the iPhone?

Hello.

There is a web admin panel written in pure php, a product is added there and any number of pictures is loaded into it at the same time.

It worked for a week, then the Iphone 11 pro stopped loading all the photos, it loads 7 out of 10, or 10 out of 15. You save the product, go into it to load exactly these photos - it doesn’t load ... No errors, nothing at all, turned on the notification of all errors php + load exceptions. Miracles are that any phone on android - loads everything with a bang, on the desktop - everything is ok. I tried to put chrome on my iPhone - it did not help.

They took the second iPhone phone, alas, it is the same - 11 pro. - 3 days loaded everything correctly and just does not load it...

Where can I dig?

<?php


Класс загрузки фото
class File {
  public static function uploadPhoto( array $uploaded_file ) {
    $ext = File::getExt( $uploaded_file['name'] );
    $initial_name = 'upload/' . uniqid( '' ) . '.jpg';
    $name = 'upload/' . sha1( $initial_name ) . '.jpg';

    $path = UPLOAD_PATH . $name;

    move_uploaded_file( $uploaded_file['tmp_name'], $path );

    return $initial_name;
  }

  public static function uploadVideo( array $uploaded_file ) {
    $ext = File::getExt( $uploaded_file['name'] );
    $name = 'upload/' . uniqid( '' ) . '.' . $ext;

    $path = UPLOAD_PATH . $name;

    move_uploaded_file( $uploaded_file['tmp_name'], $path );

    return $name;
  }

  public static function prepareFiles( array $files ) {
    $result = [];

    foreach ( $files['name'] ?? [] as $i => $item ) {
      $result[] = [
        'name' => $files['name'][$i],
        'type' => $files['type'][$i],
        'tmp_name' => $files['tmp_name'][$i],
        'error' => $files['error'][$i],
        'size' => $files['size'][$i]
      ];
    }

    return $result;
  }


  protected static function getExt( string $name ) {
    $parts = explode( '.', $name );
    return array_pop( $parts );
  }
}


photo upload page
<?php


$PAGE = [
  'aside' => true,
  'title' => 'Загрузка фото',
  'need_login' => true
];

$id = (int) $_GET['id'];
$car = Auto::getById( $id );

if ( isset( $_POST['upload'] ) ) {
  $files = File::prepareFiles( $_FILES['files'] );
  
  $photos = [];

  foreach ( $files as $file ) {
    if ( $file['type'] != 'image/jpeg' ) continue;
    $photos[] = File::uploadPhoto( $file );
  }

  Auto::addPhotos( $id, $photos );
  redirect( '?page=edit_car&id=' . $id );
}

?>


<h2>Загрузка фото: <?php echo $car['brand'] . ' ' . $car['model'] ?></h2>

    
<div class="table-wrap">
  <form action="" method="POST" enctype="multipart/form-data">
    <div class="form__row">
      <label class="form__row-label">Файлы</label>
      <div class="form__row-content">
        <input type="file" multiple class="form__input--text" name="files[]" accept="image/jpeg">
        <div class="note">Вы можете выбрать сразу несколько файлов. Изображение должно быть в формате JPG.</div>
      </div>
    </div>


    <div class="form__row">
      <label class="form__row-label"></label>
      <button class="button button--primary" name="upload">Загрузить</button>
    </div>
  </form>
</div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
higara13, 2020-09-08
@higara13

maybe because on the iphone the photo is not jpg , but heic

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question