Reputation: 5
So I have a bit of a problem. I was looking at a tutorial for video uploads and I came across this tutorial.
https://www.youtube.com/watch?v=SibODOJle6Q
It seems that my move_uploaded_files is not working and it is trivial for me to see his code work which I copied and the result is completely different.
Could I get some help with this please?
my Code below
<html>
<head>
<title>Video Upoad</title>
<link rel='stylesheet' href='stylesheet.css'/>
</head>
<body>
<?php
require('connect.php');
?>
<div id='box'>
<form method ='post' enctype='multipart/form-data'>
<?php
if(isset($_FILES['video'])){
$name= $_FILES['video']['name'];
$type = explode('.',$name);
$type=end($type);
$size= $_FILES['video']['size'];
$random_name=rand();
$tmp = $_FILES['video']['tmp_name'];
if($type !='mp4' && $type != 'MP4' && $type!='flv'){
$message = "Video Format is not supported!";
}else{
move_uploaded_file($tmp, 'viddata/'.$random_name.'.'.$type);
$message ="The Upload was successful";
mysql_query("INSERT INTO video VALUES ('','$name','viddata/$random_name.$type')");
}
echo $message.'<br/><br/>';
//echo $type.'<br/>';
//echo $name.'<br/>';
}
?>
Select Video: <br/>
<input type='file' name='video' />
<br/><br/>
<input type='submit' value='Upload' />
</form>
</div>
<div id='box'>
</div>
</body>
</html>
It does insert into the database and everything except moving the file to the destination.
Upvotes: 0
Views: 117
Reputation: 868
Start by checking the return value, errors and warnings. The documentation says:
Return Values
Returns TRUE on success.
If filename is not a valid upload file, then no action will occur, and
move_uploaded_file()
will return FALSE.If filename is a valid upload file, but cannot be moved for some reason, no action will occur, and
move_uploaded_file()
will return FALSE. Additionally, a warning will be issued.
There are also some good examples with more comprehensive error checking.
Upvotes: 1
Reputation: 5991
You should consider the following:
viddata
folder.upload_max_filesize
.php.ini
and set the upload_max_filesize
to your preferred size, then reset your XAMPP Control Panel.Upvotes: 1