при загрузке видео возникла проблема с переменной post.

пожалуйста, посмотрите код ниже

   <?php
session_start();
include "conn.php";
$sid = $_SESSION['id'];
$ipIP=$_SERVER['REMOTE_ADDR'];
$uploaddir = "mem/$sid/video/";

//Check the file is of correct format.
function checkfile($input){
$ext = array('mpg', 'wma', 'mov', 'flv', 'mp4', 'avi', 'qt', 'wmv', 'rm',    'mkv', 'MP4');
$extfile = substr($input['name'],-4);
$extfile = explode('.',$extfile);
$good = array();
@$extfile = $extfile[1];
if(in_array($extfile, $ext)){
$good['safe'] = true;
$good['ext'] = $extfile;
}else{
$good['safe'] = false;
}
return $good;
}
if(!isset($_POST['profileimage99']) || $_FILES["profileimage99"]["size"] ==''){
echo 'No file added';die;
}
// if the form was submitted process request if there is a file for uploading
if(@$_FILES["profileimage99"]["size"] < 102400000000){
//$live_dir is for videos after converted to flv
$live_dir = "mem/$sid/video/";
//$live_img is for the first frame thumbs.
$live_img = "mem/$sid/img/";
$seed = rand(11111111111193,9999999999999929) * rand(3,9);
$getEXT=substr(@$_FILES['profileimage99']['name'],-5);
$upload = $seed.$getEXT;
$uploadfile = $uploaddir .$upload;

$safe_file = checkfile(@$_FILES['profileimage99']);
if($safe_file['safe'] == 1){
if (move_uploaded_file(@$_FILES['profileimage99']['tmp_name'], $uploadfile)) {
echo "Video uploaded.";

$base = basename($uploadfile, $safe_file['ext']);
$new_file = $base.'flv';
$new_image = $base.'jpg';
$new_image_path = $live_img.$new_image;
$new_flv = $live_dir.$new_file;

require 'vendor/autoload.php';
//ececute ffmpeg generate flv
exec('ffmpeg -i '.$uploadfile.' -f flv -s 640x360 '.$new_flv.'');
//execute ffmpeg and create thumb
exec('ffmpeg  -i '.$uploadfile.' -f mjpeg -vframes 17 -s 426x240 -an '.$new_image_path.'');
echo 'Thank You For Your Video!<br/>';

//create query to store video
if(isset($_POST['title'])){$titlename=$_POST['title'];}else{$titlename='';}
if(isset($_POST['desc'])){$desc=$_POST['desc'];}else{$desc='';}
if(isset($_POST['catag'])){$catag=$_POST['catag'];}else{$catag='';}
if(isset($_POST['channel'])){$channel=$_POST['channel'];}else{$channel='';}
$dbentry_o=mysqli_query($conn,"insert into vids (uid,chid,ctid,vname,vdisc,duration,time,ip,src) values ('$sid','$channel','$catag','$titlename','$desc','00','00','$ipIP','$new_file')");
echo "donr90909090";die;
} else {
echo "Possible file upload attack!\n";
print_r($_FILES);
}

}else{

echo 'Invalid File Type Please Try Again. You file must be of type
.mpg, .wma, .mov, .flv, .mp4, .avi, .qt, .wmv, .rm'.$_FILES['profileimage99']['name'];

}
}else{
echo 'Please choose a video';die;
}
?>

я отправляю эту форму

 <form style="margin:0px;display:none;" action="videoupload.php" method="post" id="thef_op90op">
<input type="file" name="profileimage99" style="display:none;" onchange="showandfade();" id="file09_09o9_9908ij">
</form>

на страницу выше
когда я отправляю форму, я получаю сообщение об ошибке, файл не добавляется, как будто переменная post не попадает на страницу, и когда я удаляю проверку

  if(!isset($_POST['profileimage99']) || $_FILES["profileimage99"]["size"] ==''){
echo 'No file added';die;
}

Я могу загрузить некоторые файлы, обычно размером менее 2 МБ, но для больших файлов я получаю неопределенную ошибку индекса для profileimage99.

я увеличил upload_max_size из файла php.ini

Пожалуйста, обратите внимание, что форма отправляется с помощью вызова ajax

1

Решение

Вам нужно установить атрибут enctype.
Больше информации на Атрибут HTML enctype

 <form enctype="multipart/form-data" style="margin:0px;display:none;" action="videoupload.php" method="post" id="thef_op90op">
<input type="file" name="profileimage99" style="display:none;" onchange="showandfade();" id="file09_09o9_9908ij">
</form>

И если вы отправите multipart/form-data данные из profileimage99 будет в $_FILES переменная. Поэтому вы должны изменить свой запрос на следующее:

if(!isset($_FILES['profileimage99']) || $_FILES["profileimage99"]["size"] <= 0){
echo 'No file added';
}
2

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector