PDA

توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : فرم و آپلودر



shamimi
October 14th, 2010, 22:17
سلام من یک فرم با html درست کردن که اطلاعاتی که وارد می شه میاد به میل باکس حالا می خوام یک آپلودر برای فایل زیپ هم توش بگونجونم وقتی اطلاعاتشو طرف آپ می کنه باز بیاد به همون ایمیل همراه همون اطلاعات چی کار باید کنم؟

Rezash
October 14th, 2010, 22:54
<?php

class mshell_mail {
var $errstr;
var $headers;
var $textbody;
var $htmlbody;
var $attachments;
var $boundary;

// Default constructor, sets up default header and boundary.
function mshell_mail() {
$this->attachments = array();
$this->boundary = '_mshell_mail_boundary_';
$this->headers = array(
'From' => 'Metalshell Mail Class <default@mshell_mail.com>',
'MIME-Version' => '1.0',
'Content-Type' => "multipart/mixed; boundary=\"$this->boundary\""
);

$this->bodytext("Default Mail Message.");
}

// For debugging purposes you can display the body you are about
// to send.
function get_body() {
$retval = $textbody;
$retval .= $htmlbody;
foreach($this->attachments as $tblck)
$retval .= $tblck;

return $retval;
}

// Convert the values in the header array into the correct format.
function get_header() {
$retval = "";
foreach($this->headers as $key => $value)
$retval .= "$key: $value\n";

return $retval;
}

// Add your own header entry or modify a header.
function set_header($name, $value) {
$this->headers[$name] = $value;
}

// Attach a file to the message.
function attachfile($file, $type = "application/octetstream") {
if(!($fd = fopen($file, "r"))) {
$this->errstr = "Error opening $file for reading.";
return 0;
}
$_buf = fread($fd, filesize($file));
fclose($fd);

$fname = $file;
for($x = strlen($file); $x > 0; $x--)
if($file[$x] == "/")
$fname = substr($file, $x, strlen($file) - $x);

// Convert to base64 becuase mail attachments are not binary safe.
$_buf = chunk_split(base64_encode($_buf));

$this->attachments[$file] = "\n--" . $this->boundary . "\n";
$this->attachments[$file] .= "Content-Type: $type; name=\"$fname\"\n";
$this->attachments[$file] .= "Content-Transfer-Encoding: base64\n";
$this->attachments[$file] .= "Content-Disposition: attachment; " .
"filename=\"$fname\"\n\n";
$this->attachments[$file] .= $_buf;

return 1;
}

function bodytext($text) {
// Set the content type to text/plain for the text message.
// 7bit encoding is simple ASCII characters, this is default.
$this->textbody = "\n--" . $this->boundary . "\n";
$this->textbody .= "Content-Type: text/plain\n";
$this->textbody .= "Content-Transfer-Encoding: 7bit\n\n";
$this->textbody .= $text;
}

function htmltext($text) {
// Set the content type to text/html for the html message.
// Also uses 7bit encoding.
$this->htmlbody = "\n--" . $this->boundary . "\n";
$this->htmlbody .= "Content-Type: text/html\n";
$this->htmlbody .= "Content-Transfer-Encoding: 7bit\n\n";
$this->htmlbody .= $text;
}

function clear_bodytext() { $this->textbody = ""; }
function clear_htmltext() { $this->htmlbody = ""; }
function get_error() { return $this->errstr; }

// Send the headers and body using php's built in mail.
function sendmail($to = "root@localhost", $subject = "Default Subject") {
if(isset($this->textbody)) $_body .= $this->textbody;
if(isset($this->htmlbody)) $_body .= $this->htmlbody;

foreach($this->attachments as $tblck)
$_body .= $tblck;

$_body .= "\n--$this->boundary--";

mail($to, $subject, $_body, $this->get_header());
}
}
?>



<?php
/* mshell_mail class by detour@metalshell.com
*
* This is an example on how to use the mshell_mail class
* included with this project. Basically makes attaching
* files, and sending messages painless.
*
* Functions:
* # get_body() - returns the current message body.
* # get_header() - returns the current header.
* # set_header($name, $value) - alter the value of a header tag or add a
* new header tag. ie $Mail->set_header("CC", "Carbon Copy <carbon@copy.com>");
* # attachfile($file, $type) - add a file attachment to the message. The
* default type is "application/octetstream".
* # bodytext($text) - add a plain text entry to the email.
* # htmltext($text) - add an html entry to the message.
* # clear_bodytext() - remove the plain text entry.
* # clear_htmltext() - remove the html text enry.
* # get_error() - retrieve any error messages.
* # sendmail($to, $subject) - Give the headers and body to your default mail
* program, usually sendmail. Make sure your settings in php.ini have
* the correct sendmail location.
*
* http://www.metalshell.com/
*/

include('mshell_mail.php');

$to = "someones@email.com";
$from = "John Doe <return@email.com>";
$file = "file_to_attach.ext";

// Create an instance of the mshell_mail class.
$Mail = new mshell_mail();

// You can modify predefined headers or set new ones
$Mail->set_header("From", $from);

// Send a plain text message.
$Mail->bodytext("Hello\n\nThis is a plain text message.\n-bye");
$Mail->sendmail($to, "Plain Text Message");

// Send an html message.
$Mail->clear_bodytext();
$Mail->htmltext("<html><body text=\"#FF0000\">" .
"<H1>Html Message</H1></body></html>");
$Mail->sendmail($to, "Html Message");

// Send a plain text with an attachment.
$Mail->clear_htmltext();
$Mail->bodytext("Plain text message with an attached file.");
// You may attach as many files as you want.
if(!$Mail->attachfile($file))
print $Mail->get_error();
$Mail->sendmail($to, "Plain Text with Attachment");

?>

منبع :‌
PHP: PHP Mail Class (http://www.metalshell.com/source_code/115/PHP_Mail_Class.html)
يا نمونه هاي ديگه :
Attachment Mailer class (send mail, mailer, attachment, php mailer) - PHP Classes (http://www.phpclasses.org/package/2822-PHP-Send-e-mail-messages-with-attachment-files.html)

shamimi
October 16th, 2010, 10:09
دوست عزیز نشد من می خواهم این فایل و کاری کنم که توش یک آپلود سنتر داشته باشه
http://upfile.irhost.org/uploads/Form1.zip

shamimi
October 16th, 2010, 21:35
کسی از دوستان نیست کمکم کنه ؟

Rezash
October 16th, 2010, 22:51
فايل آپلود بشه و لينكس ارسال بشه يا مستقيم ضميمه بشه و با ايميل ارسال بشه؟

shamimi
October 16th, 2010, 23:09
می خوام مستقیم ضمیمه بشه با جزنیات پر شده به ایمیل ارسال بشه

Rezash
October 17th, 2010, 02:02
يك نمونه فروم ساده با همين كلاس با كمي تغيير براتون ساختم كه ميتونه فايل زيپ رو دريافت و ضميمه كنه.

shamimi
October 17th, 2010, 09:35
عزیز بعدش این فایل ها کجا آپ می شه ؟
و اینکه از کجا ایمیل خودمو بگذارم که اطلاعات می آد ؟
من اینو ست کردم ببینید درست الان دوست من...
http://up.iranblog.com/Files73/a540f1774be3456087b8.zip

Rezash
October 17th, 2010, 21:39
عزیز بعدش این فایل ها کجا آپ می شه ؟
و اینکه از کجا ایمیل خودمو بگذارم که اطلاعات می آد ؟
من اینو ست کردم ببینید درست الان دوست من...
http://up.iranblog.com/Files73/a540f1774be3456087b8.zip
فايل وقتي ارسال ميشه مثل فرآينده آپلود اول در temp ميره.بعد اگر قرار باشه آپلود دائمي باشه كه بايد move بشه ولي ما ميخوايم فقط ضميمه ايميل بشه
پس فايل رو مستقيما ضميمه كردم
فرم شما درست نيست چون مقادير رو دريافت نكرديد.
شما بايد با توجه به name مشخص شده در هر input در فرم خودتون در فايل dosend.php با استفاده از $_POST اون مقدار رو دريافت و در جاي مناسب درج و نسبت به ارسال اقدام كنيد
دمويي كه دادم رو اول تست كنيد و نتيجه رو ببينيد
سپس فايل dosend.php و form.html رو با دقت بررسي كنيد و براحتي ميتونيد فرم رو شخصي سازي كنيد.