Hi,
I am working on a site for a client and we need to allow people to upload a couple of files from a form. I have copied the script and instuctions on how to upload multiple files and adapted it, but obviously have gone wrong somewhere as am receiving this error message when I hit the "Submit" button on the form:
Parse error: syntax error, unexpected $end in /home/jioioipz/public_html/choicesescorts/uploadaction.php on line 84
The steps I have taken are as follows:
Copied the script to notepad, adapted it and published it to site as upload action.php
Created an error page, thank you page, created a new file called uploads and set permissions to 777 and obviously the form. These are titles as follows:
www.choicesescorts.co.uk/thank_you.html
www.choicesescorts.co.uk/error_page.html
www.choicesescorts.co.uk/uploads
www.choicesescorts.co.uk/recruitment.html
The script has been copiedabnd adapted as follows:
<?php
// Receiving variables
@$email = addslashes($_POST['email']);
@$upload_Name = $_FILES['upload']['name'];
@$upload_Size = $_FILES['upload']['size'];
@$upload_Temp = $_FILES['upload']['tmp_name'];
@$upload1_Name = $_FILES['upload1']['name'];
@$upload1_Size = $_FILES['upload1']['size'];
@$upload1_Temp = $_FILES['upload1']['tmp_name'];
// Validation for max file size
// Validation for the first file, if it exists. Repeat the block as many times as your upload fields.
if ($upload_Size>0)
{
if( $upload_Size >1000000)
{
//delete file
unlink($upload_Temp);
header("Location: error.html");
exit;
}
}
// Validation for the second file, if it exists. In the additional blocks, change the number 1 to 2 or 3 or ... n
if ($upload1_Size>0)
{
if( $upload1_Size >1000000)
{
//delete file
unlink($upload1_Temp);
header("Location: error.html");
exit;
}
}
// Uploading the first file, if it exists. Repeat as many times as your upload fields.
if ($upload_Size>0)
{
$uploadFile = "uploads/".$upload_Name ;
@move_uploaded_file( $upload_Temp , $uploadFile);
chmod($uploadFile, 0644);
$upload_URL = "<A href="http://www.choicesescorts.co.uk/uploads/".$upload_Name">http://www.choicesescorts.co.uk/uploads/".$upload_Name ;
// Uploading the second file, if it exists.
if ($upload1_Size>0)
{
$uploadFile = "uploads/".$upload1_Name ;
@move_uploaded_file( $upload1_Temp , $uploadFile);
chmod($uploadFile, 0644);
$upload1_URL = "<A href="http://www.choicesescorts.co.uk/uploads/".$upload1_Name">http://www.choicesescorts.co.uk/uploads/".$upload1_Name ; // You must change the number 1 to 2 or 3 or whatever in the additional blocks
}
//Sending Email to form owner
$mailto = "enquiries@choicesescorts.co.uk";
$mailsubj = "choices job application";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "job application form :\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
if ($key!="submit")
{
$mailbody .= "$key : $val\n";
}
}
$mailbody .= "File Link 1: $upload_URL\n"; // This line is to add the link to the first file. Repeat as many times as your upload fields
$mailbody .= "File Link 2: $upload1_URL\n"; // This line is to add the link to the second file.
$mailbody .= "If any link is broken, please copy and paste it in your browser's address bar\n";
mail($mailto, $mailsubj, $mailbody, $mailhead);
header("Location: thankyou_page.html");
?>
Please could Naval or somone have a quick look at what I have done and see if the mistakes I have made are obvious.
The purpose of the form is to receive the requested information to our email as well as the two uploaded files. Will it be possible using this script to have the files also sent to be viewed with the email, or if several forms are sent to us by different people how will we know which files come from which person if viewed online in the uploads file.
Many thanks in advance.
Rob
I am working on a site for a client and we need to allow people to upload a couple of files from a form. I have copied the script and instuctions on how to upload multiple files and adapted it, but obviously have gone wrong somewhere as am receiving this error message when I hit the "Submit" button on the form:
Parse error: syntax error, unexpected $end in /home/jioioipz/public_html/choicesescorts/uploadaction.php on line 84
The steps I have taken are as follows:
Copied the script to notepad, adapted it and published it to site as upload action.php
Created an error page, thank you page, created a new file called uploads and set permissions to 777 and obviously the form. These are titles as follows:
www.choicesescorts.co.uk/thank_you.html
www.choicesescorts.co.uk/error_page.html
www.choicesescorts.co.uk/uploads
www.choicesescorts.co.uk/recruitment.html
The script has been copiedabnd adapted as follows:
<?php
// Receiving variables
@$email = addslashes($_POST['email']);
@$upload_Name = $_FILES['upload']['name'];
@$upload_Size = $_FILES['upload']['size'];
@$upload_Temp = $_FILES['upload']['tmp_name'];
@$upload1_Name = $_FILES['upload1']['name'];
@$upload1_Size = $_FILES['upload1']['size'];
@$upload1_Temp = $_FILES['upload1']['tmp_name'];
// Validation for max file size
// Validation for the first file, if it exists. Repeat the block as many times as your upload fields.
if ($upload_Size>0)
{
if( $upload_Size >1000000)
{
//delete file
unlink($upload_Temp);
header("Location: error.html");
exit;
}
}
// Validation for the second file, if it exists. In the additional blocks, change the number 1 to 2 or 3 or ... n
if ($upload1_Size>0)
{
if( $upload1_Size >1000000)
{
//delete file
unlink($upload1_Temp);
header("Location: error.html");
exit;
}
}
// Uploading the first file, if it exists. Repeat as many times as your upload fields.
if ($upload_Size>0)
{
$uploadFile = "uploads/".$upload_Name ;
@move_uploaded_file( $upload_Temp , $uploadFile);
chmod($uploadFile, 0644);
$upload_URL = "<A href="http://www.choicesescorts.co.uk/uploads/".$upload_Name">http://www.choicesescorts.co.uk/uploads/".$upload_Name ;
// Uploading the second file, if it exists.
if ($upload1_Size>0)
{
$uploadFile = "uploads/".$upload1_Name ;
@move_uploaded_file( $upload1_Temp , $uploadFile);
chmod($uploadFile, 0644);
$upload1_URL = "<A href="http://www.choicesescorts.co.uk/uploads/".$upload1_Name">http://www.choicesescorts.co.uk/uploads/".$upload1_Name ; // You must change the number 1 to 2 or 3 or whatever in the additional blocks
}
//Sending Email to form owner
$mailto = "enquiries@choicesescorts.co.uk";
$mailsubj = "choices job application";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "job application form :\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
if ($key!="submit")
{
$mailbody .= "$key : $val\n";
}
}
$mailbody .= "File Link 1: $upload_URL\n"; // This line is to add the link to the first file. Repeat as many times as your upload fields
$mailbody .= "File Link 2: $upload1_URL\n"; // This line is to add the link to the second file.
$mailbody .= "If any link is broken, please copy and paste it in your browser's address bar\n";
mail($mailto, $mailsubj, $mailbody, $mailhead);
header("Location: thankyou_page.html");
?>
Please could Naval or somone have a quick look at what I have done and see if the mistakes I have made are obvious.
The purpose of the form is to receive the requested information to our email as well as the two uploaded files. Will it be possible using this script to have the files also sent to be viewed with the email, or if several forms are sent to us by different people how will we know which files come from which person if viewed online in the uploads file.
Many thanks in advance.
Rob
Comment