0
HTML, PHP 및 JS를 사용하여 동적 연락처를 만들려고합니다.이메일 첨부 파일이있는 동적 양식
지금까지 이메일을 보내고 있지만 헤더가 콘텐츠를 차단하고 첨부 파일이 이메일과 함께 전송되지 않았습니다.
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Order Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="css/default.css"/>
<script type="text/javascript" src="js/script.js"></script>
</head>
<body>
<form action="process.php" class="register" method="POST">
<h1>Artwork Upload</h1>
<fieldset class="row1">
<legend>Order Information</legend>
<p>
<label>Order No *
</label>
<input name="orderno" type="text" required="required"/>
<label>Name</label>
<input name="name" type="text" required="required" />
<label>E mail</label>
<input name="email" type="text" required="required" />
</p>
<div class="clear"></div>
</fieldset>
<fieldset class="row2">
<legend>Graphics per Product</legend>
<p>
<input type="button" value="Add more images" onClick="addRow('dataTable')" />
<input type="button" value="Remove selected lines" onClick="deleteRow('dataTable')" />
<p>(All acions apply only to entries with check marked check boxes only.)</p>
</p>
<table id="dataTable" class="form" border="1">
<tbody>
<tr>
<p>
<td><input type="checkbox" required="required" name="chk[]" checked="checked" /></td>
<td>
<label>Product code (SKU)</label>
<input type="text" required="required" name="BX_SKU[]">
</td>
<td>
<label for="BX_age">Product Name</label>
<input type="text" required="required" name="BX_Item[]">
</td>
<td>
<label for="BX_gender">Upload</label>
<input name="attachment" type="file">
</td>
<td>
<label for="BX_birth">Comments</label>
<input type="textarea" name="BX_birth" required="required">
</td>
</p>
</tr>
</tbody>
</table>
<div class="clear"></div>
</fieldset>
<input class="submit" type="submit" value="Confirm »" />
<div class="clear"></div>
</form>
</body>
PHP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>A3M Artwork Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="css/default.css"/>
</head>
<body>
<form action="" class="register">
<h1>Artwork Upload</h1>
<?php if(isset($_POST)==true && empty($_POST)==false):
$chkbox = $_POST['chk'];
$bus = $_POST['bus'];
$day = $_POST['day'];
$month = $_POST['month'];
$mob = $_POST['mob'];
$type = $_POST['type'];
$from = $_POST['from'];
$to=$_POST['to'];
$root=$_POST['root'];
$BX_NAME=$_POST['BX_SKU'];
$BX_age=$_POST['BX_age'];
$BX_gender=$_POST['BX_gender'];
$BX_birth=$_POST['BX_birth'];
// Email address to which you want to send email
$to = "[email protected]";
$subject = "A3M User Upload";
$message = "Name:";
$message = $_POST['name'];
$message = "Email:";
$message = $_POST['email'];
$message = "Order ID:";
$message = $_POST['orderno'];
$message = "Product Name:";
$message = $_POST['BX_Item[]'];
$message = "Comments:";
$message = $_POST['BX_birth]'];
/*********Creating Uniqid Session*******/
$txtSid = md5(uniqid(time()));
$headers = "";
$headers .= $_POST["name"]."<".$_POST["email"].">\nReply-To: ".$_POST["email"]."";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"".$txtSid."\"\n\n";
$headers .= "This is a multi-part message in MIME format.\n";
$headers .= "--".$txtSid."\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
$headers .= "Content-Transfer-Encoding: 7bit\n\n";
$headers .= $message."\n\n";
/***********Email Attachment************/
if($_FILES["attachment"]["name"] != "")
{
$txtFilesName = $_FILES["attachment"]["name"];
$txtContent = chunk_split(base64_encode(file_get_contents($_FILES["attachment"]["tmp_name"])));
$headers .= "--".$txtSid."\n";
$headers .= "Content-Type: application/octet-stream; name=\"".$txtFilesName."\"\n";
$headers .= "Content-Transfer-Encoding: base64\n";
$headers .= "Content-Disposition: attachment; filename=\"".$txtFilesName."\"\n\n";
$headers .= $txtContent."\n\n";
}
// @ is for skiping Errors //
$flgSend = @mail($to,$subject,null,$headers,$message);
if($flgSend)
{
echo "Email Sent SuccessFully.";
}
else
{
echo "Error in Sending Email.";
}
?>
<fieldset class="row1">
<legend>Order Information</legend>
<p>Thank you for your information. A3M Direct will be in touch</p>
<?php else: ?>
<fieldset class="row1">
<legend>Sorry</legend>
<p>Some things went wrong please try again.</p>
</fieldset>
<?php endif; ?>
<div class="clear"></div>
</form>
</body>
</html>
JS
function addRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
if(rowCount < 1000){ // limit the user from creating fields more than your limits
var row = table.insertRow(rowCount);
var colCount = table.rows[0].cells.length;
for(var i=0; i<colCount; i++) {
var newcell = row.insertCell(i);
newcell.innerHTML = table.rows[0].cells[i].innerHTML;
}
}else{
alert("Please enter 1000 at a time, or contact A3M Direct.");
}
}
function deleteRow(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
for(var i=0; i<rowCount; i++) {
var row = table.rows[i];
var chkbox = row.cells[0].childNodes[0];
if(null != chkbox && true == chkbox.checked) {
if(rowCount <= 1) { // limit the user from removing all the fields
alert("Cannot Remove all information.");
break;
}
table.deleteRow(i);
rowCount--;
i--;
}
}
}
나는 시험
01 때 얻을 이메일 23,516,Lee<[email protected]>
Reply-To: [email protected]: 1.0
Content-Type: multipart/mixed; boundary="8cd09bc06c304411f8d45359ebd270e2"
This is a multi-part message in MIME format.
--8cd09bc06c304411f8d45359ebd270e2
Content-type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit
업데이트 : (양식에에 enctype 속성을 추가 아래 응답에서받은 코드를 추가하고, 이메일
lee<[email protected]>
Reply-To: [email protected]: 1.0
Content-Type: multipart/mixed; boundary="18a2609e079b32ac5c98c954421a15f6"
This is a multi-part message in MIME format.
--18a2609e079b32ac5c98c954421a15f6
Content-type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit
--18a2609e079b32ac5c98c954421a15f6
Content-Type: application/octet-stream; name="mjweb-new-year.jpg"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="mjweb-new-year.jpg"
/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAABQAAD/4QMtaHR0cDov
L25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENl
aGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4
OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjMtYzAxMSA2Ni4xNDU2NjEsIDIwMTIvMDIvMDYtMTQ6
NTY6MjcgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5
OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHht
bG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0i
aHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1sbnM6eG1w
덕분에 나는이를 추가 한 나는 오히려 이상 이메일하지만 첨부 파일을 얻을 것을 알고있다. 내 질문에 정보를 추가하겠습니다 –
PHP 메일 기능을 사용하여 첨부 파일을 보내려고 시도한 적이 없으며 항상 PHPMailer 라이브러리를 사용합니다.이 다른 질문을 살펴보고 답변을 찾을 수 있습니다 [링크 ] (http://stackoverflow.com/questions/12301358/send-attachments-with-php-mail) – Daniel