Hi everyone, I'm totally new to PHP and I am trying to create a script that allows users to upload a picture which will then be emailed to me along with their details. When debugging, I keep receiving the message Parse error: syntax error, unexpected $end in C:\Users\Admin\Web\php-form-action.php on line 85.
Any help would be greatly appreciated.
Thanks in advance!
<?php
//Settings
$max_allowed_file_size = 5000; // size in KB
$allowed_extensions = array("jpg", "jpeg", "gif", "bmp");
$upload_folder = './uploads/';
$your_email = 'myemailaddress';//
$errors ='';
if(isset($_POST['submit']))
{
//Get the uploaded file information
$name_of_uploaded_file = basename($_FILES['uploaded_file']['name']);
//get the file extension of the file
$type_of_uploaded_file = substr($name_of_uploaded_file,
strrpos($name_of_uploaded_file, '.') + 1);
$size_of_uploaded_file = $_FILES["uploaded_file"]["size"]/1024;
///------------Do Validations-------------
if(empty($_POST['name'])||empty($_POST['email']))
{
$errors .= "\n Name and Email are required fields. ";
}
if(IsInjected($visitor_email))
{
$errors .= "\n Bad email value!";
}
if($size_of_uploaded_file > $max_allowed_file_size )
{
$errors .= "\n Size of file should be less than $max_allowed_file_size";
}
//------ Validate the file extension -----
$allowed_ext = false;
for($i=0; $i<sizeof($allowed_extensions); $i++)
{
if(strcasecmp($allowed_extensions[$i],$type_of_uploaded_file) == 0)
{
$allowed_ext = true;
}
}
if(!$allowed_ext)
{
$errors .= "\n The uploaded file is not supported file type. ".
" Only the following file types are supported: ".implode(',',$allowed_extensions);
}
//send the email
if(empty($errors))
{
//copy the temp. uploaded file to uploads folder
$path_of_uploaded_file = $upload_folder . $name_of_uploaded_file;
$tmp_path = $_FILES["uploaded_file"]["tmp_name"];
if(is_uploaded_file($tmp_path))
{
if(!copy($tmp_path,$path_of_uploaded_file))
{
$errors .= '\n error while copying the uploaded file';
}
}
$to = 'myemailaddress' ;
$subject = 'Subject' ;
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$headers = 'From: ' . $_POST [ "from" ] . PHP_EOL ;
$totalmessage = "
Name: $name \n
Email: $email \n
Message: $message \n
Uploaded File: $_FILES\n";
mail ( $to , $subject , $totalmessage , $headers );
header('location: thankyou.htm');
?>