I'm using PHP to upload mp4 video files and generate thumbnails on Linux environment and I have no Idea why my code works fine on any windows browser but when using my ios safari I get INVALID FILE.
ini_set('display_errors', 'On'); error_reporting(E_ALL);
require_once '../../vendor/autoload.php' ;
if($_FILES["upload_file"]["name"] != '')
{
$data = explode(".", $_FILES["upload_file"]["name"]);
$extension = $data[1];
$allowed_extension = array("mp4");
if(in_array($extension, $allowed_extension))
{
$name_only = pathinfo($_FILES["upload_file"]['name'], PATHINFO_FILENAME) ; // Main Name Only
$new_video_name = $name_only.'.mp4';
$new_img_name = $name_only.'.jpg';
$path = $_POST["hidden_folder_name"] .'/'. $new_video_name;
$img_path = $_POST["hidden_folder_name"] .'/'.$new_img_name ;
if(move_uploaded_file($_FILES["upload_file"]["tmp_name"], $path))
{
$ffmpeg = FFMpeg\FFMpeg::create(array(
'ffmpeg.binaries' => '/usr/local/bin/ffmpeg',
'ffprobe.binaries' => '/usr/local/bin/ffprobe',
'timeout' => 3600,
'ffmpeg.threads' => 12,
));
$video = $ffmpeg->open($path);
$video->filters()->resize(new FFMpeg\Coordinate\Dimension(320, 180))->synchronize();
$video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(5))->save($img_path);
echo 'FILE UPLOADED';
}
else
{
echo 'THERE IS AN ERROR';
}
}
else
{
echo 'INVALID FILE';
}
}
else
{
echo 'PLEASE SELECT FILE';
}
CodePudding user response:
This was causing the problem on ios Safari,
if(in_array($extension, $allowed_extension))
{
Removing that and the
else
{
echo 'INVALID FILE';
}
}
Fixed my problem.
CodePudding user response:
I guess some files are too big for safari, there also could be some weird apple nonsense certificate issue. I would consider not bothering with apple or safari as such. Your code seems perfect.