0
&をコードサンプルに含むファイルをPHPの電子メールで送信する方法はありますか? サイトからメッセージを送信した場合、連絡先電子メールが届きますが、ファイルはありません。私の次のアイデアは、 "public function mitgliedschaft"に "public function antrag"が必要だが、それは機能していないということです。Codeigniterは画像ファイルで電子メールを送信します
Antrag =イメージファイル
私がしようと何&結果>>
出力Eメール:
Vorname: Testfirstname
Nachname: Testlastname
Email: [email protected]
Steam: Testurl
Antrag:
Message: Testmessage
コントローラ
public function mitgliedschaft() {
$this->load->library('form_validation');
$this->form_validation->set_rules('vorname', 'Vorname', 'trim|required');
$this->form_validation->set_rules('nachname', 'Nachname', 'trim|required');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
$this->form_validation->set_rules('steam', 'Steam', 'trim|required');
$this->form_validation->set_rules("antrag", 'Antrag', "trim|callback_antrag[$id]");
$this->form_validation->set_rules('message', 'Message', 'trim|required');
$data['success'] = false;
if ($this->form_validation->run() == TRUE) {
@mail(config('webmaster_email'), 'Message from eraseme', ""
. "Vorname: $_POST[vorname]\n"
. "Nachname: $_POST[nachname]\n"
. "Email: $_POST[email]\n"
. "Steam: $_POST[steam]\n"
. "Antrag: $_POST[antrag]\n"
. "Message: $_POST[message]\n"
. "");
$data['success'] = true;
}
$this->load->view(__FUNCTION__, $data);
}
public function antrag($var, $id) {
$config['upload_path'] = './cdn/antrag/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$this->load->library('upload', $config);
if ($this->upload->do_upload('antrag')) {
$data = $this->upload->data();
if ($data['file_name'])
$this->{$this->model}->antrag = base_url() . '/cdn/antrag/' . $data['file_name'];
}
return true;
}
ビュー
<div class="controls">
<div class="row">
<?php if ($success) : ?>
<div class="col-md-12">
<div class="alert alert-success">
<i class="fa fa-check-circle" aria-hidden="true" style="margin-left: 7px;"></i>
Your Message Is Sent Successfully
</div>
</div>
<?php endif ?>
<?php if (validation_errors()) : ?>
<div class="col-md-12">
<div class="alert alert-danger">
<i class="fa fa-times-circle" aria-hidden="true" style="margin-left: 7px;"></i>
<?php echo validation_errors() ?>
</div>
</div>
<?php endif ?>
<div class="col-md-6">
<div class="form-group">
<label for="form_name">Vorname *</label>
<input id="form_name" type="text" name="vorname" id="vorname" class="form-control" placeholder="Please enter your firstname *" required="required" data-error="Firstname is required.">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="form_name">Nachname *</label>
<input id="form_name" type="text" name="nachname" id="nachname" class="form-control" placeholder="Please enter your lastname *" required="required" data-error="Firstname is required.">
<div class="help-block with-errors"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="form_email">Email *</label>
<input id="form_email" type="email" name="email" id="email" class="form-control" placeholder="Please enter your email *" required="required" data-error="Valid email is required.">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="form_phone">Steam URL</label>
<input id="form_phone" type="tel" name="steam" id="steam" class="form-control" placeholder="Please enter your Steam URL or ID">
<div class="help-block with-errors"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<input class="form-control" type="file" name="antrag" >
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="form_message">Message *</label>
<textarea id="form_message" name="message" id="message" class="form-control" placeholder="Message for me *" rows="4" required="required" data-error="Please,leave us a message."></textarea>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-12">
<input type="submit" id="send" class="btn btn-success btn-send whibtn" style="margin:0;" value="Send message">
</div>
</div>
</div>