Ich habe das gleiche Problem. Andere Dateien doc, xls hochgeladen fein. aber das Hochladen von PDF gibt einen Fehler. „Der Dateityp Sie versuchen, ist zum Hochladen nicht erlaubt.“ in config/mimnes.php ich habe:Warum schlägt der PDF-Upload auf Codeigniter 1.7.2 fehl?
'pdf' => array('application/pdf', 'application/x-download', 'application/download'),
in Controllern ich habe:
function upload_file($type, $upload_type)
{
$this->load->library('upload');
//upload file
switch($upload_type){
case "image":
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|jpg|png|pdf';
$config['max_size'] = '3000';
$config['max_width'] = '3224';
$config['max_height'] = '1268';
break;
case "doc":
$config['upload_path'] = './uploads/pages/doc/';
$config['allowed_types'] = 'pdf|doc|docx|xls|ppt';
$config['max_size'] = '3000';
$config['encrypt_name'] = TRUE;
break;
}
foreach($_FILES as $key => $value)
{
if(! empty($value['name']))
{
$this->upload->initialize($config);
if (! $this->upload->do_upload($key))
{
$errors = array('error' => $this->upload->display_errors());
$this->session->set_flashdata('flashError', $errors);
}
else
{
$this->page_model->process_file($type, $upload_type);
}
}
}
}
jede Hilfe spürbar sein wird.
i Config wie $ initialisierte this-> upload-> initialize ($ config); es ist nicht nötig, zweimal dasselbe zu tun. – kamal
Sind Sie sicher, dass Sie den richtigen Wert in $ upload_type haben? –
ya $ upload_type ist korrekt. aber heute, was ich herausgefunden habe, ist: ich bin in der Lage, Datei alternativ hochzuladen. wenn ich eine doc-datei und eine pdf-datei hochlade, werden beide hochgeladen. und wenn ich pdf-Datei nur hochladen es nicht. was könnte der Grund sein. – kamal