I have a form that has four fields, and the last field is an upload-file field. I want the user to upload a video file, which must be in one of four formats. The uploaded video will be placed in a folder on my server. Once the form submits, an email is sent to me and the form fields are stored in a database.I am getting emails and seeing the information in my database, but I cannot get the upload onto my server. Also, file types that I want to accept are being told that it's not acceptable. For instance, I tried to upload a .mov file and got the message: The file is not a video format we accept.I have been talking to some colleagues of mine but I cannot get this fixed. Can someone take a look at this code and offer any advice? Here is my code:
<?php //ftp acess$host = "ftp.hostname.com";$usr = "username";$password = "pass";//This is the directory where images will be saved$local_file = $_FILES['video']['tmp_name'];$ftp_path = "/upload/".$_FILES['video']['name'];$type = $_FILES['video']['type'];$size = $_FILES['video']['size'];if($size < 151000000) {if(($type == 'video/mpeg') || ($type =='video/mov') || ($type =='video/mp4') || ($type =='video/mpg') || ($type =='video/avi')) {//connect to the FTP server$conn = ftp_ssl_connect($host, 21) or die("Can't connect to the host!");ftp_login($conn, $usr, $password) or die("Cannot login"); $upload = ftp_put($conn, $ftp_path, $local_file, FTP_ASCII);// check upload status:} else {echo "The file is not a video format we accept";}} else {echo "The size of the file is to large";}// close the FTP streamftp_close($conn);//This gets all the other information from the form$name=$_POST['name'];$email=$_POST['email'];$phone=$_POST['phone'];$vid=addslashes(basename($_FILES['video']['name']));// Connects to your Databasemysql_connect("localhost", "username", "pass") or die("Error connect: ".mysql_error()) ;mysql_select_db("database_name") or die("Can't connect to Database".mysql_error()) ;//Writes the information to the database$query = "INSERT INTO video (videoid, Name, Email, Phone, Video) VALUES ('','$name', '$email', '$phone', '$vid')";if(!mysql_query($query)){ echo "Error uploading information";}else { $headers = 'From: '.$email. "\r\n" . 'Reply-To: '.$email. "\r\n". 'X-Mailer: PHO/' . phpversion(); $message = "Name: ".$name . "\r\n"; $message .= "Email : ".$email . "\r\n"; $message .= "Phone number: ".$phone. "\r\n";; $message .= "Video file: ". $vid; mail("myemail@gmail.com", "Video uploaded", $message,$headers);header('Location: http://mysite.com/submit/thank-you.php') ;}?>
Thank you in advance for any help you can provide.