I am very to this forum and I hope to find my answer to the question I have. I have a php file which is responsible to upload files to my server after a form is submitted. At the moment when someone upload a file with a name that has space when an email is sent to me the link to the file is sent broken! Therefore when I click on the link to view the file and download it it gives me a 404 error.
Can anyone check the code below and tell me what needs to be added to have any files uploaded to have the hyphen added to them as well as the link sent to me has the correct name (with hyphens) so when downloading it works fine?
<?php
include("class.phpmailer.php");
$mail = new PHPMailer();
$EmailFrom = "info@fireflylocums.com"; //info@fireflylocums.com
$EmailTo = "uk.hamza@gmail.com"; // jeannine@fireflylocums.com
$Subject = "A message from Firefly Locums Website";
$Title = Trim(stripslashes($_POST['Title']));
$Firstname = Trim(stripslashes($_POST['Firstname']));
$Surname = Trim(stripslashes($_POST['Surname']));
$Address = Trim(stripslashes($_POST['Address']));
$Postcode = Trim(stripslashes($_POST['Postcode']));
$Email = Trim(stripslashes($_POST['Email']));
$Daytime = Trim(stripslashes($_POST['Daytime']));
$Evening = Trim(stripslashes($_POST['Evening']));
$Mobile = Trim(stripslashes($_POST['Mobile']));
$Current = Trim(stripslashes($_POST['Current']));
$Sought = Trim(stripslashes($_POST['Sought']));
$Additional= Trim(stripslashes($_POST['Additional']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "Title: ";
$Body .= $Title;
$Body .= "\n";
$Body .= "Firstname: ";
$Body .= $Firstname;
$Body .= "\n";
$Body .= "Surname: ";
$Body .= $Surname;
$Body .= "\n";
$Body .= "Address: ";
$Body .= $Address;
$Body .= "\n";
$Body .= "Postcode: ";
$Body .= $Postcode;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Daytime: ";
$Body .= $Daytime;
$Body .= "\n";
$Body .= "Evening: ";
$Body .= $Evening;
$Body .= "\n";
$Body .= "Mobile: ";
$Body .= $Mobile;
$Body .= "\n";
$Body .= "Current: ";
$Body .= $Current;
$Body .= "\n";
$Body .= "Sought: ";
$Body .= $Sought;
$Body .= "\n";
$Body .= "Additional: ";
$Body .= $Additional;
$Body .= "\n";
$mail->Host = "localhost"; // SMTP server
$mail->From = $EmailFrom;
$mail->Subject = "A message from Firefly Locums Website";
$mail->AddAddress($EmailTo, "");
if (is_uploaded_file($_FILES['uploadedfile']['tmp_name']))//
{
move_uploaded_file ( $_FILES['uploadedfile']['tmp_name'] , "files/".$_FILES['uploadedfile']['name'] );
chmod("files/". $_FILES['uploadedfile']['name'] , 0777);
// $mail->AddAttachment ("files/".$_FILES['uploadedfile']['name']);
$mail->Body = $Body . " http://www.fireflylocums.co.uk/files/" . $_FILES['uploadedfile']['name'];
}
else
$mail->Body = $Body;
if(!$mail->Send())
{
print "Mailer Error: " . $mail->ErrorInfo;
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
else
{
if (is_uploaded_file($_FILES['uploadedfile']['tmp_name']))
{
// unlink("files/".$_FILES['uploadedfile']['name']);
}
print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
?>
The link to the site
http://fireflylocums...register_cv.php
Thank you in advance.

New Topic/Question
Reply



MultiQuote





|