관리-도구
편집 파일: testattach.php
<?php print_r($_FILES); $new_image_name = "image".rand(10, 20).".jpg"; $email_to = "guy@azimpact.com"; // The email you are sending to (example) $email_from = "cascade1@host2.cascadewindows.com'"; // The email you are sending from $email_subject = "Upload: ".$_GET["album"]; // The Subject of the email $email_txt = "the body text"; // Message that the email has in it $fileatt = $_FILES["file"]["tmp_name"]; // Path to the tmp file $fileatt_type = "image/jpeg"; // File Type $fileatt_name = "upload.jpg"; // Filename that will be used for the file as the attachment $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers="From: $email_from"; // Who the email is from (example) $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_txt; $email_message .= "\n\n"; $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; mail($email_to,$email_subject,$email_message,$headers); if (mail($email_to,$email_subject,$email_message,$headers)) { move_uploaded_file($_FILES["file"]["tmp_name"], "/home/finest09/public_html/picuploads/".$new_image_name); } else { echo "[B]email could not be sent[/B]"; } ?>