在基于linux的服务器上使用php-pear包无法接收附件



下面是我发送附件的代码。任何帮助都是有用的。enter code here提前谢谢。

send_attach.php

<?php
@include_once 'Mail.php'
@include_once 'Mail/mime.php' ;
$hdrs['email'] = $mime;
$headers['To'] = $work_mail;
$headers['Subject'] = "Application For Job";
$headers['Content-type'] = "text/html; charset=windows-1251";
$headers['MIME-Version'] = "1.0";
$text = 'Text version of email';
$html = '<html><body>HTML version of email</body></html>';
$file = '/studylink.txt';
$crlf = "n";
$hdrs = array(
              'From'    => 'me@here.com',
              'Subject' => 'Test mime message'
               );
$mime = new Mail_mime(array('eol' => $crlf));
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$mime->addAttachment($file, 'text/plain');
$body = $mime->get();
$body=$mime->get(array('html_charset'=>'windows-1251','text_charset'=>'windows-1251','head_charset'=>'windows-1251'));
$hdrs = $mime->headers($hdrs);
@$mail =& Mail::factory('mail');
@$mail->@$mail->send('there@somewhere.com', $hdrs, $body);
?>

send_file.html

<form action="send_attach.php" method="post" enctype="multipart/form-data">
  <table width="35%" border="0" align="center" cellpadding="0" cellspacing="6">
    <tr class="style14">
      <td width="16%">Name <span class="style8">*</span></td>
      <td width="84%"><input type="text" placeholder="Name" name="name" id="name" for='name'></td>
    </tr>
    <tr class="style14">
      <td>Email <span class="style8">*</span></td>
      <td> <input type="text" name="email" id="email" for='email' placeholder="Email"> </td>
    </tr>
    <tr class="style14">
      <td>Phone</td>
      <td> <input name="phone" type="text" id="phone" for='phone' maxlength="10" placeholder="Numbers Only"></td>
    </tr>
    <tr class="style14">
      <td valign="top">Employment <br />
        Eligibility <span class="style8">*</span></td>
      <td valign="middle">
    <select name="work" class="style14" id="work">
          <option selected="selected">--- select option ---</option>
          <option>a</option>
          <option>b</option>
          <option>c`enter code here`</option>
        </select>      </td>
    </tr>`enter code here`
    <tr class="style14">
      <td>Experience<br />
Summary <span class="style8">*</span></td>
      <td valign="middle"><textarea name="summary" cols="35" rows="2" id="summary" placeholder="Experience Summary"></textarea></td>
    </tr>
    <tr>
      <td valign="top" class="style14">Resume<span class="style8"> * </span></td>
      <td><label>
        <input name="attachment" type="file" for='resume_uploaded_file'>
      </label></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="reset" name="Reset" id="button" value="Reset" />
      <input type="submit" name="btn_get" id="btn_get" value="Submit" /></td>
    </tr>
  </table>
</form>

在您提供的示例中,您似乎没有将文件上传到文件系统。您需要处理从表单POST上传的文件,将文件放在文件系统上,然后确保添加时正确引用了它。/file查看的是服务器的根,而不是您网站所在的web服务器的根。

如果你做file_exists('/studylink.txt')

我猜这个文件不存在。

相关内容

  • 没有找到相关文章

最新更新