faufau
faufau

Reputation: 43

move_upload_file not work for upload video

I want to upload video (like mp4, wvm, flv) with form submit but move_file_upload() not working.

This is my code :

<?php
if (isset($_POST['submit'])) {
			$errors = array();
			$allowed_e = array('mp4', 'flv', 'wmv');

			$file_name = $_FILES['video2']['name'];
			$file_e = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
			$file_s = $_FILES['video2']['size'];
			$file_tmp = $_FILES['video2']['tmp_name'];
			$t_name = @$_POST['topic_name'];
			 $content = @$_POST['content'];
 			$date = date("y-m-d");
			if (in_array($file_e, $allowed_e) == false) {
			$errors[] = 'ext not allowed';
			}

			if ($file_s > 20097152) {
			$errors[] = 'File must be under 20mb';
			}
			

			if (empty($errors)) {
			$rawBaseName = pathinfo($file_name, PATHINFO_FILENAME );
		    $extension = pathinfo($file_name, PATHINFO_EXTENSION );
		    $counter1 = 1;
		    $counter2 = 1;
			    while(file_exists('video/'.$file_name)) {
			    $file_name = $rawBaseName . $counter1 . $counter2 .'.' . $extension;
			    $counter1++; 
				$counter2++;}
			move_uploaded_file($file_tmp, 'video/'.$file_name);
			$video2_up = 'video/'.$file_name;
			if ($posttopic = "INSERT INTO topics (topic_id, topic_name, topic_content, topic_creator, date, video)
	 					 VALUES ('', '".$t_name."', '".$content."', '".$_SESSION["username"]."', '".$date."', '".$video2_up."')" ){
						$conn->exec($posttopic);
					}header("Location: index.php");
							
			

			}else{
				foreach ($errors as $error) {
					echo $error, '</br>';
				}
			}

		}
?>

But when I remove that extension allowed and upload some image it works please give me solution.

Upvotes: 0

Views: 50

Answers (1)

Dileep Kumar
Dileep Kumar

Reputation: 1107

I think the problem is with the file size. Check your php.ini file and increase the limit for following php directives:

post_max_size = 20M
upload_max_filesize = 20M

After making the above changes, restart you web server.

Upvotes: 0

Related Questions