Wp_mail attachment
-
[ Moderator note: moved to How-to and Troubleshooting. ]
Hi,
wp_mail attachment not working with directory path…
here is my code[ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]
<?php error_reporting(E_ALL); /* Plugin Name: Add New Product Plugin URI: Description: This allows vendors to add new prodcut Author: Prakash Version: 1.0 Author URI: */ add_shortcode('add_new','new_prod'); function new_prod() { global $wpdb; $current_user = wp_get_current_user(); $user = $current_user->user_login; $id = $current_user->ID; $mail = $current_user->user_email; // mkdir("../wcvendor/wp-content/plugins/add New Product/uploads/$user"); ?> <html> <head> <title>Add New Product</title> <style> table td { float: inside; border:#000; } </style> </head> <body> <form action="" method="post" enctype="multipart/form-data" name="form1"> <table border="" style="border-color:#FFFFFF;"> <?php $file_name = 'General_Template.xls'; ?> <div style="text-align: center"> <tr><td><h3>Upload Template With Product images</h3></td></tr> <tr><td><input class="test" id='upload' name="upload[]" type="file" multiple="multiple" /></td></tr> <tr><td><h3>Image Format</h3></td></tr> <tr><td>To add products on to your store on taazataaza.com upload your catalogue along with the images: You can upload the files with the following formats: .JPEG .PNG .XML .CSV .tar.gz .gz </td></tr> <tr><td><h3>Do not worry if you dont have a catalogue ready, you can use our template and prepare one.Fill in and upload.</h3></td></tr> <tr><td><h3>Download Sample Template</h3></td></tr> <tr><td><form action="<?php echo ('downloadFile.php?page=file');?>" method="post" enctype="multipart/form-data" name="form2"><a>">Click here to download template</a></form></td></tr> <tr><td><input class="button btn btn-flat-orange" type="submit" name="submit" value="submit"></td></tr> </div></table> </form> </body> </html> <?php if(isset($_POST['submit'])) { if(count($_FILES['upload']['name']) > 0){ //Loop through each file for($i=0; $i<count($_FILES['upload']['name']); $i++) { //Get the temp file path $tmpFilePath = $_FILES['upload']['tmp_name'][$i]; //Make sure we have a filepath if($tmpFilePath != ""){ //save the filename $shortname = $_FILES['upload']['name'][$i]; //save the url and the file $filePath = "../new_theme/wp-content/uploads/product/" . date('d-m-Y-H-i-s').'-'.$_FILES['upload']['name'][$i]; //Upload the file into the temp dir if(move_uploaded_file($tmpFilePath, $filePath)) { $files[] = $shortname; } } } } echo $count= count($files); } $attachments = array( WP_CONTENT_DIR. '/new_theme/wp-content/uploads/product/06-05-2016-07-08-22-download.jpg' ); wp_mail('[email protected]','test','',$attachments); echo "<img src='/new_theme/wp-content/uploads/product/06-05-2016-07-08-22-download.jpg'>"; echo "<img src=".$attachments[0].">"; echo $attachments[0]; } }
- The topic ‘Wp_mail attachment’ is closed to new replies.