묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
제 홈페이지에 꼭!! 필요합니다.
2002.09.16 20:37
폼메일에서 파일 업로드해서 메일 첨부파일로
받고 싶은데 잘 안되네요. 제가 워낙 초보라서...
cgi로 되어있는데 그냥 텍스트는 잘되는데
이미지 첨부는 가질 않아요.
제발 누가 아시는분 올려주세요. ㅠ.ㅠ
제가 이게 꼭!!! 필요하거든요.
아래에 소스 올립니다.
고수님들의 수정 부탁드립니다.
아래는 cgi 소스입니다.
----------------------------------
#!/usr/bin/perl
######################################################################
######################################################################
#ONLY EDIT THIS PART OF THE SCRIPT!!!!
$backurl = "http://www.xxxxo.net/";
$backname = "homepage";
$mailprog = '/usr/lib/sendmail'+ '+ ';
$youmail = 'xxx@xxx.co.kr';
$yourname = "sxxx";
# DO NOT EDIT BELOW THIS LINE!!!!
#################################################################
# Receive info from Fill in Form
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Process info from Fill in Form
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$INPUT{$name} = $value;
}
# Post the usernames and passwords in the file.
# open (PASS, "|perl $htpasswd $htpasswdloc $INPUT{'username'} $INPUT{'password'}>/dev/null 2>&1") || die "Can't open $htpasswdloc!";
# close(PASS);
# 아래부분은 홈페이지 주인이 받을 내용입니다.
open (MAIL, "|$mailprog $youmail") || die "Can'+ 't open $mailprog!n";
if ($INPUT{'email'} =~ /(.*)@(.*)/) {
print MAIL "From: $INPUT{'email'} <$INPUT{'email'}>n";
} else {
print MAIL "From: $INPUT{'+ 'email'}n";
}
print MAIL "Subject: 신청서nn";
print MAIL "$INPUT{'name'} 님이 신청하신 신청서입니다.nn";
print MAIL "------------------------------------------------------n";
print MAIL "▶ 성명: $INPUT{'name'}";
print MAIL "▶ 주민등록번호: $INPUT{'number1'}- $INPUT{'number2'}n";
print MAIL "▶ 우편번호: $INPUT{'zip1'}-$INPUT{'zip2'}n";
print MAIL "▶ 자택주소: $INPUT{'homeaddress'}n";
print MAIL "▶ 전화번호: $INPUT{'dial'}n";
print MAIL "▶ 휴대폰: $INPUT{'beeper'}n";
print MAIL "▶ 홈페이지주소: $INPUT{'workaddress'} n";
print MAIL "------------------------------------------------------n";
print MAIL "▶ 특기: $INPUT{'skill'}n";
print MAIL "▶ 요구사항: $INPUT{'textarea'}n";
print MAIL "------------------------------------------------------n";
close (MAIL);
# 입력양식을 다썼을때 보여지는 글입니다.
print "Content-Type: text/htmlnn";
print "<html><head><title>감사합니다.</title></head>n";
print "<body bgcolor=white><center><p>n";
print "<p><br><P>n";
print "<p><br><P>n";
print "<p><br><P>n";
print "<p><br><P>n";
print "<p><br><P>n";
print "<p><br><P>n";
print "<center>감사합니다.<br></center>n";
print "<p><br><P>n";
print " $INPUT{'name'} 님이 작성하신 신청서입니다.n";
print "</center><P><br><P><br>n";
print "<p><br><P>n";
print "</body></html>n";
exit;
sub required {
print "Content-type: text/htmlnn";
print "<html>n";
print "<head><title>ERROR-You must fill asterisk section</title></head>n";
print "<body bgcolor=#ffffff text=#000000>n";
print "<br><br><br><CENTER><FONT SIZE=3>Error - You must fill * section to be a member.</FONT></CENTER>n";
print "<br><br><CENTER><FONT SIZE=3>에러 - * 부분을 입력해 주셔야만 회원가입이 가능합니다.</FONT></CENTER>n";
print "</body></html>n";
exit;
}
--------------------------------
아래는 html 폼형식
-----------------------------------------------------------------------
<HTML>
<HEAD>
<TITLE>온라인 신청서</TITLE>
<META http-equiv="content-type" content="text/html; charset=EUC-KR">
</HEAD>
<BODY bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<FORM name="theForm" method="post" action="form.cgi" onsubmit="
if(this.name.value == '') {
alert('신청인의 이름을 기입해주세요.');
return false;}">
<P align="center"> <DIV align="center"><TABLE border="0" cellpadding="0" width="421" height="400"><CAPTION align="bottom">
</CAPTION>
<TR>
<TD width="417" colspan="2" bgcolor="#F3F6ED" height="35">
<table align="center" border="1" cellspacing="0" width="417" bordercolor="#CCCCCC" bordercolordark="#CCCCCC" bordercolorlight="#CCCCCC">
<tr>
<td width="411" height="57"><P align="center"><b>신
청 서</b></td>
</tr>
</table>
</TD>
</TR><TR>
<TD width="26%" bgcolor="#EEEEEE" height="21"><P align="right"><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b>성
명
: </b></span></FONT></TD>
<TD width="73%" bgcolor="#F6F6F6" height="21"><P><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b> <INPUT type="text"
name="name" size="10"></b></span></FONT></TD>
</TR><TR>
<TD width="26%" bgcolor="#EEEEEE" height="21"><P align="right"><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b>e-mail
:</b></span></FONT></TD>
<TD width="73%" bgcolor="#F6F6F6" height="21"><P><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b> <INPUT type="text"
name="email" size="23"> </b></span></FONT></TD>
</TR><TR>
<TD width="26%" bgcolor="#EEEEEE" height="21"><P align="right"><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b>자택주소
:</b></span></FONT></TD>
<TD width="73%" bgcolor="#F6F6F6" height="21"><P><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b> <INPUT type="text"
name="homeaddress" size="31"></b></span></FONT></TD>
</TR><TR>
<TD width="26%" bgcolor="#EEEEEE" height="21"><P align="right"><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b>전화번호
:</b></span></FONT></TD>
<TD width="73%" bgcolor="#F6F6F6" height="21"><P><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b> <INPUT type="text"
name="dial" size="15"> </b></span></FONT></TD>
</TR><TR>
<TD width="26%" bgcolor="#EEEEEE" height="21">
<p align="right"><span style="font-size:9pt;"><b><font color="#006600">이미지
보내기</font></b></span></p>
</TD>
<TD width="73%" bgcolor="#F6F6F6" height="21"><input type=file name="userfile" size=20 value=''></TD>
</TR><TR>
<TD width="26%" height="21" bgcolor="#EEEEEE"><P align="right">
<span style="font-size:10pt;"><font color="#006600"><b>요구사항 :</b></font></span><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b>
</b></span></FONT></TD>
<TD width="73%" height="21" bgcolor="#F6F6F6"><P><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b> <TEXTAREA name="textarea"
rows="3" cols="37">
</TEXTAREA><br> </b></span></FONT></TD>
</TR><TR>
<TD width="417" colspan="2" bgcolor="#F3F6ED" height="38"> <p align="center"> </p>
</TD>
</TR></TABLE><TABLE border="3" cellpadding="0" cellspacing="0">
<TR>
<TD><P align="left"><font
size="2"><INPUT type="submit" value=" 신 청"></font></TD>
<TD><P align="left"><font
size="2"><INPUT type="reset" value=" 취 소"></font></TD>
</TR></TABLE></DIV>
</FORM>
<p></p>
<p align="center"> </p>
</body>
</HTML>
받고 싶은데 잘 안되네요. 제가 워낙 초보라서...
cgi로 되어있는데 그냥 텍스트는 잘되는데
이미지 첨부는 가질 않아요.
제발 누가 아시는분 올려주세요. ㅠ.ㅠ
제가 이게 꼭!!! 필요하거든요.
아래에 소스 올립니다.
고수님들의 수정 부탁드립니다.
아래는 cgi 소스입니다.
----------------------------------
#!/usr/bin/perl
######################################################################
######################################################################
#ONLY EDIT THIS PART OF THE SCRIPT!!!!
$backurl = "http://www.xxxxo.net/";
$backname = "homepage";
$mailprog = '/usr/lib/sendmail'+ '+ ';
$youmail = 'xxx@xxx.co.kr';
$yourname = "sxxx";
# DO NOT EDIT BELOW THIS LINE!!!!
#################################################################
# Receive info from Fill in Form
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Process info from Fill in Form
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$INPUT{$name} = $value;
}
# Post the usernames and passwords in the file.
# open (PASS, "|perl $htpasswd $htpasswdloc $INPUT{'username'} $INPUT{'password'}>/dev/null 2>&1") || die "Can't open $htpasswdloc!";
# close(PASS);
# 아래부분은 홈페이지 주인이 받을 내용입니다.
open (MAIL, "|$mailprog $youmail") || die "Can'+ 't open $mailprog!n";
if ($INPUT{'email'} =~ /(.*)@(.*)/) {
print MAIL "From: $INPUT{'email'} <$INPUT{'email'}>n";
} else {
print MAIL "From: $INPUT{'+ 'email'}n";
}
print MAIL "Subject: 신청서nn";
print MAIL "$INPUT{'name'} 님이 신청하신 신청서입니다.nn";
print MAIL "------------------------------------------------------n";
print MAIL "▶ 성명: $INPUT{'name'}";
print MAIL "▶ 주민등록번호: $INPUT{'number1'}- $INPUT{'number2'}n";
print MAIL "▶ 우편번호: $INPUT{'zip1'}-$INPUT{'zip2'}n";
print MAIL "▶ 자택주소: $INPUT{'homeaddress'}n";
print MAIL "▶ 전화번호: $INPUT{'dial'}n";
print MAIL "▶ 휴대폰: $INPUT{'beeper'}n";
print MAIL "▶ 홈페이지주소: $INPUT{'workaddress'} n";
print MAIL "------------------------------------------------------n";
print MAIL "▶ 특기: $INPUT{'skill'}n";
print MAIL "▶ 요구사항: $INPUT{'textarea'}n";
print MAIL "------------------------------------------------------n";
close (MAIL);
# 입력양식을 다썼을때 보여지는 글입니다.
print "Content-Type: text/htmlnn";
print "<html><head><title>감사합니다.</title></head>n";
print "<body bgcolor=white><center><p>n";
print "<p><br><P>n";
print "<p><br><P>n";
print "<p><br><P>n";
print "<p><br><P>n";
print "<p><br><P>n";
print "<p><br><P>n";
print "<center>감사합니다.<br></center>n";
print "<p><br><P>n";
print " $INPUT{'name'} 님이 작성하신 신청서입니다.n";
print "</center><P><br><P><br>n";
print "<p><br><P>n";
print "</body></html>n";
exit;
sub required {
print "Content-type: text/htmlnn";
print "<html>n";
print "<head><title>ERROR-You must fill asterisk section</title></head>n";
print "<body bgcolor=#ffffff text=#000000>n";
print "<br><br><br><CENTER><FONT SIZE=3>Error - You must fill * section to be a member.</FONT></CENTER>n";
print "<br><br><CENTER><FONT SIZE=3>에러 - * 부분을 입력해 주셔야만 회원가입이 가능합니다.</FONT></CENTER>n";
print "</body></html>n";
exit;
}
--------------------------------
아래는 html 폼형식
-----------------------------------------------------------------------
<HTML>
<HEAD>
<TITLE>온라인 신청서</TITLE>
<META http-equiv="content-type" content="text/html; charset=EUC-KR">
</HEAD>
<BODY bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<FORM name="theForm" method="post" action="form.cgi" onsubmit="
if(this.name.value == '') {
alert('신청인의 이름을 기입해주세요.');
return false;}">
<P align="center"> <DIV align="center"><TABLE border="0" cellpadding="0" width="421" height="400"><CAPTION align="bottom">
</CAPTION>
<TR>
<TD width="417" colspan="2" bgcolor="#F3F6ED" height="35">
<table align="center" border="1" cellspacing="0" width="417" bordercolor="#CCCCCC" bordercolordark="#CCCCCC" bordercolorlight="#CCCCCC">
<tr>
<td width="411" height="57"><P align="center"><b>신
청 서</b></td>
</tr>
</table>
</TD>
</TR><TR>
<TD width="26%" bgcolor="#EEEEEE" height="21"><P align="right"><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b>성
명
: </b></span></FONT></TD>
<TD width="73%" bgcolor="#F6F6F6" height="21"><P><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b> <INPUT type="text"
name="name" size="10"></b></span></FONT></TD>
</TR><TR>
<TD width="26%" bgcolor="#EEEEEE" height="21"><P align="right"><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b>e-mail
:</b></span></FONT></TD>
<TD width="73%" bgcolor="#F6F6F6" height="21"><P><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b> <INPUT type="text"
name="email" size="23"> </b></span></FONT></TD>
</TR><TR>
<TD width="26%" bgcolor="#EEEEEE" height="21"><P align="right"><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b>자택주소
:</b></span></FONT></TD>
<TD width="73%" bgcolor="#F6F6F6" height="21"><P><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b> <INPUT type="text"
name="homeaddress" size="31"></b></span></FONT></TD>
</TR><TR>
<TD width="26%" bgcolor="#EEEEEE" height="21"><P align="right"><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b>전화번호
:</b></span></FONT></TD>
<TD width="73%" bgcolor="#F6F6F6" height="21"><P><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b> <INPUT type="text"
name="dial" size="15"> </b></span></FONT></TD>
</TR><TR>
<TD width="26%" bgcolor="#EEEEEE" height="21">
<p align="right"><span style="font-size:9pt;"><b><font color="#006600">이미지
보내기</font></b></span></p>
</TD>
<TD width="73%" bgcolor="#F6F6F6" height="21"><input type=file name="userfile" size=20 value=''></TD>
</TR><TR>
<TD width="26%" height="21" bgcolor="#EEEEEE"><P align="right">
<span style="font-size:10pt;"><font color="#006600"><b>요구사항 :</b></font></span><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b>
</b></span></FONT></TD>
<TD width="73%" height="21" bgcolor="#F6F6F6"><P><FONT face="굴림" color="#006600"><span style="font-size:10pt;"><b> <TEXTAREA name="textarea"
rows="3" cols="37">
</TEXTAREA><br> </b></span></FONT></TD>
</TR><TR>
<TD width="417" colspan="2" bgcolor="#F3F6ED" height="38"> <p align="center"> </p>
</TD>
</TR></TABLE><TABLE border="3" cellpadding="0" cellspacing="0">
<TR>
<TD><P align="left"><font
size="2"><INPUT type="submit" value=" 신 청"></font></TD>
<TD><P align="left"><font
size="2"><INPUT type="reset" value=" 취 소"></font></TD>
</TR></TABLE></DIV>
</FORM>
<p></p>
<p align="center"> </p>
</body>
</HTML>