728x90
반응형

폴더내 파일 검색

$dir = $_SERVER[DOCUMENT_ROOT]."/upload/";

$files = scandir($dir);

foreach($files as $i => $value) {

  if (substr($value, 0, 1) == .) {
    unset($files[$i]);
  }
}

메일발송

<?
header("Content-Type: text/html; charset=utf-8");
function mailto($MAIL_FROM_NAME,$MAIL_FROM,$MAIL_TO,$MAIL_SUBJ,$body)
{
    $mailheaders = "Return-Path: <$MAIL_FROM> \r\n";
    $mailheaders .= "From: =?utf-8?B?".base64_encode($MAIL_FROM_NAME)."?=  <{$MAIL_FROM}>\r\n";
    $mailheaders .= "X-Mailer: JOYNET Interface\r\n";

    $boundary = "--------" . uniqid("part");

    $mailheaders .= "MIME-Version: 1.0\r\n";
    $mailheaders .= "Content-Type: multipart/alternative; boundary=\"=_NextPart_$boundary\"";

    $bodytext  = "This is a multi-part message in MIME format.\r\n\r\n";
    $bodytext .= "--=_NextPart_$boundary\r\n";
    $bodytext .= "Content-Type: text/plain; charset=utf-8\r\n";
    $bodytext .= "Content-Transfer-Encoding: base64\r\n\r\n";
    $bodytext .= ereg_replace("(.{80})","\\1\r\n",base64_encode(strip_tags($body))) . "\r\n\r\n";

    $bodytext .= "--=_NextPart_$boundary\r\n";
    $bodytext .= "Content-Type: text/html; charset=utf-8\r\n";
    $bodytext .= "Content-Transfer-Encoding: base64\r\n\r\n";

    $bodytext .= ereg_replace("(.{80})","\\1\r\n",base64_encode(stripslashes($body)));
    $bodytext .= "\r\n\r\n--=_NextPart_$boundary--\r\n";
    $result = mail($MAIL_TO, =?utf-8?B? . base64_encode($MAIL_SUBJ) . ?=,$bodytext,$mailheaders);

    return $result;
}


$from_name = "ts";
$from = "eldkqhdl@ts.co.kr";
$to = "eldkqhdl@naver.com";
$subject = "이건 될려나?";
$body = "대충 내용 들어가는칸";

if(mailto($from_name, $from, $to, $subject, $body)) {
 echo "<script type=text/javascript>alert(발송성공);location.href=index.php;</script>";
} else {
 echo "<script type=text/javascript>alert(발송실패);location.href=index.php;</script>";
}
?>

$HTTP_POST_FILES 와 $_FILES 설정

$HTTP_POST_FILES =& $_FILES;

or

$_FILES =& $HTTP_POST_FILES;

=& 의 기호는 우측의 내용을 좌측에 포함한다는 뜻

php가 4.1 버전을 기준으로 이상은 $_FILES 를 사용하고

이하는 $HTTP_POST_FILES 를 사용한다.

부득이하게 사용해야 할 경우 소스와 같은 형태를 취해주면

어떤 모양이든 사용 가능!!

엑셀로 출력하기

<?php
$titledate("Ymd")." 리스트";
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename".$title.".xls");
header("Content-Description : PHP4 Generated Data ");
?>

php용 페이지 엑셀출력
제일 상단에 적용함.

728x90
반응형

'back-end > ASP & PHP' 카테고리의 다른 글

[PHP] 유용한 코드2  (0) 2023.06.19
[ASP] 버블소트  (0) 2023.06.19
[ASP] 글자수 제한 .... 붙여리턴  (0) 2023.06.19
[ASP] 날짜/주/월 더한 날 구하기  (0) 2023.06.19
[ASP] 랜덤값 생성  (0) 2023.06.19

+ Recent posts