Getting File Upload to work
My action code is in a separate file, and I've tried to move code as best as I can guess.
The file upload is not working as a consequence. I will also have an issue adding the attachment to email as a second item.
Here's the form code:
<?php
if (!isset($_SESSION)) {
session_start();
}
?>
<?php require_once( "../../WA_SecurityAssist/Helper_PHP.php" ); ?>
<?php
if (!WA_Auth_RulePasses("Customer Access")){
WA_Auth_RestrictAccess("accessdenied.php");
}
require_once("../../WA_DigitalFilePro/HelperPHP.php");
//WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
//WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "../uploads",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "0",
'ResizeWidth' => "0",
'ResizeHeight' => "0",
'ResizeFillColor' => "" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmln
.
.
.
<form enctype="multipart/form-data" action="processsupportrequest.php" method="post" name="form1" class="FormContent" id="form1">
.
.
<tr>
<td>Attachments:</td>
<td><span id="sprytextfield6">
<input name="upload" id="upload" type="file"/>
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
Here's the processing code:
<?php
if (!isset($_SESSION)) {
session_start();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
require_once('../../Connections/Centerline.php'); ?>
<?php require_once("../../WA_DigitalFilePro/HelperPHP.php"); ?>
<?php require_once("../../WA_Universal_Email/mail_PHP.php"); ?>
<?php require_once("../../WA_Universal_Email/MailFormatting_PHP.php"); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php';
$securimage = new Securimage();
if ($securimage->check($_POST['captcha_code']) == true) {
// capthca entered correctly
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
WA_DFP_UploadFiles("WA_UploadResult1", $_FILES["upload"], "3", "[ExistingFileName]_[Increment]", "false", $WA_UploadResult1_Params);
//WA Universal Email object="mail"
//Send Loop Once Per Entry
$RecipientEmail = "support@centerlinesft.com";include("../../WA_Universal_Email/WAUE_processsupportrequest_1.php");
//Send Mail All Entries
header("Location: ");
$insertGoTo = "thankyouemail.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
else {
print '<p align="center" style="color: #DD0000; font-weight: bold;">Incorrect verification code</p>';
print '<p align="center"><a href="javascript:history.go(-1);">Go back and try again</a></p>';
}
?>
</body>
</html>
And the email template:
<?php
$MailAttachments = "";
$MailBCC = "";
$MailCC = "";
$MailTo = "";
$MailBodyFormat = "";
$MailBody = "";
$MailImportance = "";
$MailFrom = "Centerline Support Page|WA|support@centerlinesft.com";
$MailSubject = "Support Request - " . $_POST["Name"];
$_SERVER["QUERY_STRING"] = "";
//Global Variables
$WA_MailObject = WAUE_Definition("mail.allabuzz-ci.com","25","support@centerlinesft.com","","","");
if ($RecipientEmail) {
$WA_MailObject = WAUE_AddRecipient($WA_MailObject,$RecipientEmail);
}
else {
//To Entries
}
//Attachment Entries
//BCC Entries
//CC Entries
//Body Format
$WA_MailObject = WAUE_BodyFormat($WA_MailObject,0);
//Set Importance
$WA_MailObject = WAUE_SetImportance($WA_MailObject,"3");
//Start Mail Body
$MailBody = $MailBody . "<html><head></head><body>\r\n";
$MailBody = $MailBody . "\r\n";
$MailBody = $MailBody . "<p>Name: ";
$MailBody = $MailBody . ((isset($_POST["Name"]))?$_POST["Name"]:"");
$MailBody = $MailBody . "</p>\r\n";
$MailBody = $MailBody . "<p>Email: ";
$MailBody = $MailBody . ((isset($_POST["Email"]))?$_POST["Email"]:"");
$MailBody = $MailBody . "</p>\r\n";
$MailBody = $MailBody . "<p>Comments: ";
$MailBody = $MailBody . ((isset($_POST["Comments"]))?$_POST["Comments"]:"");
$MailBody = $MailBody . "</p>\r\n";
$MailBody = $MailBody . "<p>Attachment: ";
$MailBody = $MailBody . ((isset($_FILES["upload"]))?$_FILES["upload"]:"");
$MailBody = $MailBody . "</p>\r\n";
$MailBody = $MailBody . "</body></body></html>";
//End Mail Body
$WA_MailObject = WAUE_SendMail($WA_MailObject,$MailAttachments,$MailBCC,$MailCC,$MailTo,$MailImportance,$MailFrom,$MailSubject,$MailBody);
$WA_MailObject = null;
?>