0
저는 PHP를 처음 사용하는 사람입니다. 양식에서 전자 메일로 업로드하여 자신에게 보낼 파일 두 개를 가져 오려고합니다. 이것은 아마 쉬운 일이지만 지난 3 시간 동안 그것을 얻지 못했습니다.두 개의 파일을 양식에서 전자 메일에 첨부하십시오.
내가보기에 파일 정보를 얻을 수있었습니다. 이것을 어떻게 첨부합니까? 그게 내가 문제가되는 곳이야.
이것은 양식에서 두 개의 파일 (및 기타 데이터)을 수신하는 코드입니다.이 사이트는 도움이된다면 SermonPublish.com입니다.
도움 주셔서 감사합니다.
표준 변수를 가져옵니다.
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$cover = "cover: " . test_input($_POST["cover"]) . "\n";
$authorname = "Author Name: " . test_input($_POST["authorName"]) . "\n";
$booktitle = "Title: " . test_input($_POST["bookTitle"]) . "\n";
$subtitle = "Subtitle: " . test_input($_POST["subtitle"]) . "\n";
$description = "Description: " . test_input($_POST["description"]) . "\n";
$aboutauthor = "About Author: " . test_input($_POST["aboutAuthor"]) . "\n";
$clientnumber = "Client Number: " . test_input($_POST["clientNumber"]) . "\n";
$payment = "Payment: " . test_input($_POST["payment"]) . "\n";
$address = "Address: " . test_input($_POST["address"]) . "\n";
$agreement = "Agree: " . test_input($_POST["agreement"]) . "\n";
$email = test_input($_POST["email"]);
파일 업로드에 대한 세부 정보를 확인하십시오.
//Get the uploaded file information
$author_photo_name =
basename($_FILES['authorPhoto']['name']);
$author_photo_type =
substr($author_photo_name,
strrpos($author_photo_name, '.') + 1);
$author_photo_size =
$_FILES["authorPhoto"]["size"]/1024;//size in KBs
//Get the uploaded file information
$sermon_name =
basename($_FILES['sermon']['name']);
$sermon_type =
substr($sermon_name,
strrpos($sermon_name, '.') + 1);
$sermon_size =
$_FILES["sermon"]["size"]/1024;//size in KBs
}
좋아, 이제 어떻게 첨부 하시겠습니까? 제안
$subject = "Sermon Submission";
$message = $cover . $authorname . $booktitle . $subtitle . $description . $aboutauthor . $clientnumber . $payment . $address . $agreement . $email;
$message = wordwrap($message, 70);
// send mail
mail("[email protected]",$subject,$message,"From: $email\n");
echo "Thank you for your submission. We will contact you as soon as it is processed.";
?>
php의 mail()은 phpmailer와 같은 라이브러리로 제한적으로 전환됩니다. –