From: Steve Sutton Date: Fri, 26 May 2017 12:35:39 +0000 (-0400) Subject: Adding file upload X-Git-Tag: v1.0.0^2~1^2~2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=cedbb63f438e8c94f1be52b7e561206eec64d3f5;p=WP-Plugins%2Fglm-support-form.git Adding file upload Add file for upload and test that file added as attachment. --- 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 +