0

i know this question have been asked multiple times before but I am new to php.

Using a html form to post video and videotitle i am getting Undefined index:on multiple lines of my code. i have read about isset but is not sure if i need to implement the code and how to do so. any help is appreciated.

Undefined index: on line 4, 9, 11, 13, 17, 18, 19, 20, 21

 <?php

$allowedExts = array("jpg", "jpeg", "gif", "png", "mp3", "mp4", "wma");
$extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
$filePath = dirname(__FILE__);
$videoname = $_POST['videoTitle'];

$target_dir = "original/"; //where you want to upload the files to
$target_file = $target_dir.basename($_FILES['file']['name']); // orginial file name
$fileType = pathinfo($target_file, PATHINFO_EXTENSION);
$newFileName = $target_dir.'480p/'.sha1(pathinfo(basename($_FILES['file']['name']), PATHINFO_FILENAME)).'480p'.'.'.$fileType; // new file name
//$newFileName = $target_dir.sha1(pathinfo(basename($_FILES['file']['name']), PATHINFO_FILENAME)).'-'.time().'.'.$fileType;
move_uploaded_file($_FILES['file']['tmp_name'], $target_file);
$unique_id = rand(1000000,9999999); // generate unique id for compressed video
$uOrig_id = rand(1000000,9999999); // generate unique id for orginial video

if ((($_FILES["file"]["type"] == "video/mp4")
|| ($_FILES["file"]["type"] == "audio/mp3")
|| ($_FILES["file"]["type"] == "audio/wma")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg"))

&& ($_FILES["file"]["size"] < 1073741274    )
&& in_array($extension, $allowedExts))

using isset but it still don't work.

if (!isset($extension)) $extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);

0 Answers0