Download video from iPad - PHP

Stuck on some weird bugs. Created an ipad web application to upload videos from the ipad gallery to my web server. Displaying the wrong file format, the same video directly from a desktop browser, works great. Is there a problem with the iPad or a problem like mime. See my code.

<?php
ini_set('max_execution_time', 2400);
$path = "uploads/";

$name = $_FILES['photoimg']['name'];


$size = $_FILES['photoimg']['size'];
$valid_formats = array("mp4", "MP4","jpg","avi","AVI");
list($txt, $ext) = explode(".", $name);

$errors = array(); 
$form_data = array();

if(!empty($name))
{
    if(in_array($ext,$valid_formats))
    {
        if ($size<(1024*1024*1024*1024*1024*1024*1024*1024*1024*1024*1024*1024*1024*1024))
        {
            $actual_image_name = time().substr(str_replace(" ", "_", $txt), 5).".".$ext;
            $tmp = $_FILES['photoimg']['tmp_name'];

        } else {
            $errors['imgsize'] = 'Image file size max issue.<br/>';
        }

    } else{
        $errors['imgformat'] = 'Invalid file format..<br/>';
    }
}


if (!empty($errors)) {
    $form_data['success'] = false;
    $form_data['errors']  = $errors;
} else { 
    $form_data['success'] = true;
    $form_data['posted'] = '1';

    move_uploaded_file($tmp, $path.$actual_image_name);
}

//Return the data back to form.php

header('Content-type: application/json');
echo json_encode($form_data);   
?>
+4
source share
1 answer

I ran into a similar problem that the ipad / iphone does compress and change the format to MOV regardless of the format. If you download mp4, it will convert to MOV. Since your code does not check the MOV format so that it throws an error. Add mov format and it will work. Welcome:)

+2
source

Source: https://habr.com/ru/post/1619729/


All Articles