From cedbb63f438e8c94f1be52b7e561206eec64d3f5 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 26 May 2017 08:35:39 -0400 Subject: [PATCH] Adding file upload Add file for upload and test that file added as attachment. --- controllers/admin.php | 17 ++++++++++++++++- views/supportForm.php | 14 +++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/controllers/admin.php b/controllers/admin.php index a974273..0cd3cc0 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -119,11 +119,26 @@ class SupportAdmin 'Time: ' . date('H:i:s ') . "\n" . 'User-Agent: ' . $_SERVER['HTTP_USER_AGENT'] . "\n" . 'Remote-Addr: ' . $_SERVER['REMOTE_ADDR'] . "\n"; + + $attachment = ''; + if ( isset( $_FILES ) && is_array( $_FILES ) + && isset( $_FILES['file_upload'] ) && !$_FILES['file_upload']['error'] ) { + // move the uploaded file + $upload_path = wp_upload_dir(); + $file_name = $upload_path['basedir'] . '/' . $_FILES['file_upload']['name']; + $fileUploaded = move_uploaded_file( $_FILES['file_upload']['tmp_name'], $file_name ); + echo '
$_FILES: ' . print_r( $_FILES, true ) . '
'; + if ( $fileUploaded ) { + $attachment = $fileUploaded; + } + } + wp_mail( GLM_SUPPORT_SUPPORT_EMAIL.','.$email.','.$values['email'], GLM_SUPPORT_SUBJECT, $msg, - $hdrs + $hdrs, + $attachment ); } } diff --git a/views/supportForm.php b/views/supportForm.php index 85fff0a..5017e35 100644 --- a/views/supportForm.php +++ b/views/supportForm.php @@ -59,7 +59,7 @@ margin: 1em 0; } table { - width: 600px; + width: 610px; } .req { color: red; @@ -74,7 +74,7 @@

Please provide as much information as you can.

-
+ @@ -127,6 +127,14 @@ + + + +
Please help us provide the proper support
+ * Upload a screenshot: (jpg,gif,png) + + +
@@ -138,4 +146,4 @@ - \ No newline at end of file + -- 2.17.1