Welcome Guest, Not a member yet? Register   Sign In
[Weird problem] - Upload config not loading
#1

[eluser]Mauricio de Abreu Antunes[/eluser]
My config/upload.php is not working anymore.
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
|
| Config de upload de arquivos
|
*/

//Path
$config['upload_path']   =   FCPATH . 'upload/';
$config['allowed_types'] =   'gif|jpg|jpeg|png|doc|docx';
//4mb aproximadamente.
$config['max_size']   =  1024 * 4;
//Tamanho da foto
$config['max_width']   =  1024;
$config['max_height']   =  768;
//Thumbnail.
$config['thumbnail_width'] =  100;
$config['thumbnail_height'] =  100;
$config['encrypt_name']  =  true;

This is my upload.php

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
* Classe MY_Upload
* Library para upload de arquivos
*
* @package CodeIgniter
* @subpackage MY_Upload
* @author Mauricio de Abreu Antunes
* @copyright Copyright (c) Percutz
* @since Version 1.0 02/2012
*/

class MY_Upload extends CI_Upload {
  
  /**
   * Construtor
   */
  public function __construct () {
   parent::__construct();
  }
  
  /**
   * Faz upload dos arquivos
   *
   * @access  public
   * @return  array   array contendo as informações do upload
   */
  public function upload_arquivos() {
   $upload_info   = false;
   $upload_arquivos  = $_FILES;
      
   if (isset($upload_arquivos)) {
    /**
     * Caso o path passado não exista, dar a possibilidade de criar.
     * Preferencialmente, passar os parâmetros corretos de paths nos controllers.
     */
    if (!file_exists($this->upload_path)) {
     //Cria o diretório, suprimindo erros.
     @mkdir($this->upload_path, 0700, true);
    }
    //Faz o upload do arquivo.
    foreach ($upload_arquivos as $arquivo=>$foto) {
     if (!$this->do_upload($arquivo)) {
      $retorno = 'erro';
     } else {
      $retorno = 'sucesso';
     }
     $upload_info[$retorno][] = array_merge ($this->data(),
        array('mensagem' => $this->display_errors()));
    }
   }
  
   //Retorna o que aconteceu com as solicitações
   return $upload_info;
  }
} // Fim da classe MY_Upload

/* Fim do arquivo MY_Upload.php */
/* Localização: ./application/libraries/MY_Upload.php */
#2

[eluser]Mauricio de Abreu Antunes[/eluser]
Well, i can echo upload_path and i can access that but my directory does not appear to be valid.
What's wrong?
#3

[eluser]Silviu[/eluser]
Hello,

First, after you define the config array, how do you pass it to the upload library? If you use
Code:
$this->load->library('upload',$config)
make sure you are not already loading the library somewhere before, as AFAIK this will cause the library not to load again and practically it will remain configured with the previous values. Try
Code:
$this->upload->initialize($config)

Second, it's not necessary to use FCPATH as the current path is always the one where CI's index.php file resides in.
So you can simply use
Code:
$config['upload_path']   =   './upload/';
(this is just a note, your config is correct as defined)

Third, there are some keys into your config array that are not native to the upload library. I haven't checked if they could mess something in the upload library, but you should try commenting them out.

Fourth, have you double checked the path and the permissions? Try 777 on the directory as last resort.
#4

[eluser]Mauricio de Abreu Antunes[/eluser]
[quote author="Silviu" date="1334130904"]Hello,

First, after you define the config array, how do you pass it to the upload library? If you use
Code:
$this->load->library('upload',$config)
make sure you are not already loading the library somewhere before, as AFAIK this will cause the library not to load again and practically it will remain configured with the previous values. Try
Code:
$this->upload->initialize($config)

How i said, i have a config file. Following codeigniter manual, it loads when load upload library. Am i right?
http://ellislab.com/codeigniter/user-gui...ading.html [Setting preferences in a config file]


Second, it's not necessary to use FCPATH as the current path is always the one where CI's index.php file resides in.
So you can simply use
Code:
$config['upload_path']   =   './upload/';
(this is just a note, your config is correct as defined)

I'm using FCPATH because my 'upload' directory is in 127.0.0.1/percutz/upload

Third, there are some keys into your config array that are not native to the upload library. I haven't checked if they could mess something in the upload library, but you should try commenting them out.

Yes, those keys are valids. Just 'thumbnail' config are not valids. Is it messing? Maybe. I'll try comment them out:
Follow the manual link again:
http://ellislab.com/codeigniter/user-gui...ading.html [Explanation]

Fourth, have you double checked the path and the permissions? Try 777 on the directory as last resort.
It's ok.
[/quote]

Thanks for the reply!
#5

[eluser]Mauricio de Abreu Antunes[/eluser]
Wow, i commented them out and stills not working.
Another idea?




Theme © iAndrew 2016 - Forum software by © MyBB