我有一個很大的表單,允許用戶上傳多個文件/文件類型到他們正在創建的報價/出價。除了一件事之外,一切都運行良好:在保存到數據庫之前對文件進行名稱加密。Codeigniter多文件上傳加密問題
我還沒有找到它的韻或理由,但它的命中或錯過。該圖像每次都能正常工作。其他文件(允許所有[*]類型,但主要包括各種業務文檔,例如pdf,doc,xls等)都是不明確的。
我在SO和其他地方發現了有關名稱加密常見問題的線程,但尚未遇到一個涉及我的問題的特殊性的線程。
這裏的上傳功能:
//for multi uploads
function do_uploads($name, $file)
{
$status ="";
$msg = "";
$file_element_name = $name;
//go through and figure out where it goes
if($name == "QuoteDoc") {
$folder = "quotedocs";
$allowed = '*';
}
else if($name == "ProductOfferPhoto") {
$folder = "product_photos";
$allowed = 'jpeg|jpg|png|gif';
}
else if($name == "ResearchWhtPaper1" || $name == "ResearchWhtPaper2") {
$folder = "research";
$allowed = "*";
}
else if($name == "ProductLiterature1" || $name == "ProductLiterature2") {
$folder = "literature";
$allowed = "*";
}
else if ($name == "FDALink") {
$folder = "fda";
$allowed = "*";
}
$config['upload_path'] = './uploads/' . $folder;
$config['allowed_types'] = $allowed;
$config['max_size'] = 1024 * 8;
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
if (! $this->upload->do_upload($name))
{
$status = 'error';
$msg = $this->upload->display_errors('', '');
}
else {
$data = $this->upload->data();
}
@unlink($_FILES[$file_element_name]);
//what's up?
//return $this->upload->data();
return array('status' => $status, 'msg' => $msg, 'data' => $this->upload->data(), 'allowed'=>$allowed);
}
任何幫助將不勝感激。
那麼你得到了什麼文件名?原本的 ? – Aurel 2013-05-04 18:09:57
是,文件名。 – 2013-05-04 19:29:59
對不起,但問題是上傳過程後,'$ this-> upload-> data()'中沒有加密文件名? – Aurel 2013-05-04 19:41:16