glenelkins Posted July 8, 2006 Share Posted July 8, 2006 One of the things iv never looked at in php is Email Attachments. Is there any decent tutorials for this around? I dont mean those crappy tutorials going on about MIME i know that stuff and dont care, i want to know how to do it in PHP lol.cheers peeps Quote Link to comment https://forums.phpfreaks.com/topic/14010-php-email-attachments/ Share on other sites More sharing options...
glenelkins Posted July 10, 2006 Author Share Posted July 10, 2006 So noone going to reply then? Quote Link to comment https://forums.phpfreaks.com/topic/14010-php-email-attachments/#findComment-55597 Share on other sites More sharing options...
Ninjakreborn Posted July 10, 2006 Share Posted July 10, 2006 For one not many people will with you being rude. You need to learn some respect before asking questions.What kind of tutorial do you mean, mime is what it's all about, I fought for 2 months with file uploading. You have to get the file is uploaded, only means it is put in temporary memory, after htat you have to check if it was uploaded or not, if it exists, then move it, then whatever else you want to do with it then, rename it, database information ex cetera, like this.[code]<?php$management = true;$errorhandler = "";$filemanager = true;$dateinfo = strtotime("now");$dateformatted = date("n-d-y", $dateinfo);if ($_POST['name'] == "") { $errorhandler .= "The Name field has been left blank<br />"; }if ($_POST['keywords'] == "") { $errorhandler .= "The Keywords were left blank<br />"; }if(!is_uploaded_file($_FILES['file']['tmp_name'])){ $errorhandler .= "No file has been uploaded<br />"; $filemanager = false; } if ($filemanager === true) {$_accepted_extensions = array('.tiff', '.png', '.mpeg', '.mpg', '.wav', '.avi', '.mid', '.jpg', '.txt', '.gif', '.mp3', '.jpeg', '.gif', '.swf', '.swc', '.flv', '.mov', '.ram', '.rm', '.ra', '.rpm', '.asf', '.wma', '.wmv', '.wm', '.asf', '.wma', '.wm', '.avi', '.mpeg', '.mpg', '.mp2', '.mp3', '.mid', '.midi', '.wav'); if ($filemanager == true) { $tmp = pathinfo($_FILES['file']['name']); if (in_array('.' . $tmp['extension'],$_accepted_extensions)) { $filemanager = true; $management = true; }else { $filemanager = false; $management = false; $errorhandler .= "You have attempted to upload the wrong file type<br />"; $errorhandler .= "We only accept mpeg, mpg, wav, avi, mid, jpg<br />"; $errorhandler .= "jpeg, pdf, txt, gif, and mp3 formats<br />"; $errorhandler .= "To request new file types email<br />"; $errorhandler .= "information@theyellowpagesnetwork.com"; } } } // Relative URL with desired folder name and the name of the file on the user's machineif ($management === true && $filemanager === true) { $newfile = "uploads/".basename($_FILES['file']['name']); $newfiletemp = "{$_FILES[file][tmp_name]}"; if (file_exists($newfile)) { $errorhandler .= "The file already exists"; $filemanager = false; } if($filemanager === true) { if (!move_uploaded_file($newfiletemp, $newfile)) { $errorhandler .= "The file was not moved properly"; $filemanager = false; $manager = false; } } }if ($filemanager === true || $manager === true) { $connect = mysql_connect("localhost", "#####", "#####"); $select = mysql_select_db("funnyemailforwards"); if (!$connect && !$select) { $errorhandler .= "The database could not connect, or selected"; $management = false; $filemanager = false; } }if ($filemanager === true && $management === true) {$query = "SELECT * from fileinfo WHERE type = '" . implode("", $_POST['type']) . "' AND nameoffunny = '" . mysql_real_escape_string($_POST['name']) . "' AND keywords = '" . mysql_real_escape_string($_POST['keywords']) . "' AND funnyurl = '" . mysql_real_escape_string($newfile) . "' AND entrydate = '" . mysql_real_escape_string($dateinfo) . "'";$result = mysql_query($query);$matches = mysql_num_rows($result); if ($matches == 0) { $name = $_POST['name']; $name = strtolower($name); $name = str_replace(" ", "", $name);$inserter = "INSERT INTO fileinfo (type, nameoffunny, keywords, funnyurl, entrydate) VALUES ('" . implode("", $_POST['type']) . "', '" . mysql_real_escape_string($name) . "', '" . mysql_real_escape_string($_POST['keywords']) . "', '" . mysql_real_escape_string($newfile) . "', '" . mysql_real_escape_string($dateinfo) . "')"; if(mysql_query($inserter)){ $management = true; $filemanager = true; }else { $management = false; $filemanager = false; $errorhandler .= "The information was not inserted into the database properly"; echo mysql_error(); } } else { $filemanager = false; $managment = false; $errorhandler .= "The information was already in the database, could not complete"; } }if ($management === false || $filemanager === false) { echo "{$errorhandler}"; } else{ echo "Everything worked out smoothly"; } ?>[/code]That right there handled the entire process for me, and I am still working on this script, I ahve to set up something to allow it to change the filename if they name it the same thing 2 times, and some otehr small functionality but this should give you the general idea. Quote Link to comment https://forums.phpfreaks.com/topic/14010-php-email-attachments/#findComment-55624 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.