私はCodeIgniterが新しくなっていますが、私は何かを把握できます。 ユーザー登録時にアップロードされたファイル(pdfおよびdoc)を管理者に表示またはダウンロードさせたいという問題に直面しています。 すべてうまくいっていますが、管理者がファイル名を見るだけでなく、ファイルをダウンロードしてもらいたいです。ここCodeIgniterでダウンロード可能なリンクとしてアップロードしたファイル(PDF、DOCなど)を表示する方法
は私のコントローラである。
<?php
クラスNominationControllerはCI_Controllerここ{
public function __construct() {
parent::__construct();
$this->load->model('Nomination');
$this->load->library('session');
}
/*
function for manage Nomination.
return all Nominations.
created by your name
created at 25-07-16.
*/
public function manageNomination() {
$data["Nominations"] = $this->Nomination->getAll();
$this->load->view('Nomination/manage-Nomination', $data);
}
/*
function for add Nomination get
created by your name
created at 25-07-16.
*/
public function addNomination() {
$this->load->view('Nomination/add-Nomination');
}
/*
function for add Nomination post
created by your name
created at 25-07-16.
*/
public function addNominationPost() {
$data['title'] = $this->input->post('title');
$data['first_name'] = $this->input->post('first_name');
$data['last_name'] = $this->input->post('last_name');
$data['email_id'] = $this->input->post('email_id');
$data['phone_no'] = $this->input->post('phone_no');
$data['company'] = $this->input->post('company');
$data['popularity'] = $this->input->post('popularity');
$data['nominee_type'] = $this->input->post('nominee_type');
$data['innovation_name'] = $this->input->post('innovation_name');
$data['organisation_type'] = $this->input->post('organisation_type');
$data['category'] = $this->input->post('category');
$data['date_of_innovation'] = $this->input->post('date_of_innovation');
$data['company_offices'] = $this->input->post('company_offices');
$data['need_addressed'] = $this->input->post('need_addressed');
$data['user_benefits'] = $this->input->post('user_benefits');
$data['uniqueness'] = $this->input->post('uniqueness');
if ($_FILES['supporting_documents']['name']) {
$data['supporting_documents'] = $this->doUpload('supporting_documents');
}
$this->Nomination->insert($data);
$this->session->set_flashdata('success', 'Nomination added Successfully');
redirect('success');
}
/*
function for edit Nomination get
returns Nomination by id.
created by your name
created at 25-07-16.
*/
public function editNomination($Nomination_id) {
$data['Nomination_id'] = $Nomination_id;
$data['Nomination'] = $this->Nomination->getDataById($Nomination_id);
$this->load->view('Nomination/edit-Nomination', $data);
}
/*
function for edit Nomination post
created by your name
created at 25-07-16.
*/
public function editNominationPost() {
$Nomination_id = $this->input->post('Nomination_id');
$Nomination = $this->Nomination->getDataById($Nomination_id);
$data['title'] = $this->input->post('title');
$data['first_name'] = $this->input->post('first_name');
$data['last_name'] = $this->input->post('last_name');
$data['email_id'] = $this->input->post('email_id');
$data['phone_no'] = $this->input->post('phone_no');
$data['company'] = $this->input->post('company');
$data['popularity'] = $this->input->post('popularity');
$data['nominee_type'] = $this->input->post('nominee_type');
$data['innovation_name'] = $this->input->post('innovation_name');
$data['organisation_type'] = $this->input->post('organisation_type');
$data['category'] = $this->input->post('category');
$data['date_of_innovation'] = $this->input->post('date_of_innovation');
$data['company_offices'] = $this->input->post('company_offices');
$data['need_addressed'] = $this->input->post('need_addressed');
$data['user_benefits'] = $this->input->post('user_benefits');
$data['uniqueness'] = $this->input->post('uniqueness');
if ($_FILES['supporting_documents']['name']) {
$data['supporting_documents'] = $this->doUpload('supporting_documents');
unlink('./uploads/Nomination/'.$Nomination[0]->supporting_documents);
}
$edit = $this->Nomination->update($Nomination_id,$data);
if ($edit) {
$this->session->set_flashdata('success', 'Nomination Updated');
redirect('success');
}
}
/*
function for view Nomination get
created by your name
created at 25-07-16.
*/
public function viewNomination($Nomination_id) {
$data['Nomination_id'] = $Nomination_id;
$data['Nomination'] = $this->Nomination->getDataById($Nomination_id);
$this->load->view('Nomination/view-Nomination', $data);
}
/*
function for delete Nomination created by your name
created at 25-07-16.
*/
public function deleteNomination($Nomination_id) {
$delete = $this->Nomination->delete($Nomination_id);
$this->session->set_flashdata('success', 'Nomination deleted');
redirect('manage-Nomination');
}
/*
function for activation and deactivation of Nomination.
created by your name
created at 25-07-16.
*/
public function changeStatusNomination($Nomination_id) {
$edit = $this->Nomination->changeStatus($Nomination_id);
$this->session->set_flashdata('success', 'Nomination '.$edit.' Successfully');
redirect('manage-Nomination');
}
/*
function for upload files
return uploaded file name.
created by your name
created at 25-07-16.
*/
public function doUpload($file) {
$config['upload_path'] = './uploads/Nomination';
$config['allowed_types'] = '*';
$this->load->library('upload', $config);
if (! $this->upload->do_upload($file))
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
return $data['upload_data']['file_name'];
}
}
}
ここに私View.php
<tr>
<td width='30%' class='label-view text-right'>
<?php echo SiteHelpers::activeLang('Uniqueness', (isset($fields['uniqueness']['language'])? $fields['uniqueness']['language'] : array())) ;?>
</td>
<td><?php echo $row['uniqueness'] ;?> </td>
</tr>
<tr>
<td width='30%' class='label-view text-right'>
<?php echo SiteHelpers::activeLang('Supporting Documents', (isset($fields['supporting_documents']['language'])? $fields['supporting_documents']['language'] : array())) ;?>
</td>
<td><?php echo $row['supporting_documents'] ;?></td>
</tr>
あるを拡張します私の出力のスクリーンショットはされています
..just in case its not set correctly
私は小さなその何かを感じるが、私の目玉は、過去1週間の痛みであり、私はGoogleが知っていると思う: I would like the pdf file or doc to be clickable
ここでは、私は私のMySQLを設定している方法です私の名前と私が今眠っているところ:
助けがあれば、どんな助けも遠く離れます。 は、ドキュメントによると、あなたに
アンカータグを使用しますか? 'Text to display' – DinosaurHunter
@DinosaurHunterあなたは文字通り私の人生、私のボール(私の目のもの)と私の日を救った。それは魅力のように働いた。祝福されています。感謝万円。 – PaulMDG