Welcome Guest, Not a member yet? Register   Sign In
Uploading file errors
#1

[eluser]Rubiz'[/eluser]
Well, I couldnt finde a problem like mine in forum, so I'm posting.

I have a form with multiple fields, like name, thumb name, image description, and others.
I sent information ok via $_POST[].

But now, I need to upload pictures. Ok, so I started to write codes, this is my upload controller:
Code:
class Upload extends Controller {
    
    function Upload()
    {
        parent::Controller();
        $this->load->helper(array('form', 'url'));
        $this->load->library('upload');
    }

    function imoveis_uploadImg($arquivoImg, $sessao, $subsessao, $tipo)
    {
        $config['upload_path'] = 'http://www.villabranca.com.br/neotix/imgs/upload/' . $sessao . '/' . $subsessao . '/' . $tipo . '/';
        $config['allowed_types'] = 'gif|GIF|jpg|JPG|jpeg|JPEG|png|PNG';
        $config['max_size']    = '500';
        $config['max_width']  = '776';
        $config['max_height']  = '420';
        
        $this->load->library('upload', $config);
    
        if ( ! $this->upload->do_upload($arquivoImg))
        {
            echo 'alert("não foi possível fazer o upload da imagem")';
        }
    }
}

And this is the method in controller I have posted form information:
Code:
$arquivoImg = 'img_plantas';
$arquivoThumb = 'thumb_plantas';
$this->upload->imoveis_uploadImg($arquivoImg, $sessao, $subsessao, $tipo);

I dont know if I is possible do this, this way I'm trying.
Any idea for solution?
#2

[eluser]xwero[/eluser]
You have to be certain the directory (path) has permissions to write the file to that is the most common bug when a file needs to be uploaded.

a tip about the error message. It's better to return instead of echo a string in functions. If you echo the string and then build your page for example the string will be at the top of your viewport.
#3

[eluser]Rubiz'[/eluser]
But so, it doesnt exists any terrible logical error in my code?

I was thinking about the input names, I didnt set it in var with $_FILES[] .. it doesnt matter?
And yes, I'm trying to upload to a web site from local site... I dont know if I have permissions.
#4

[eluser]ELRafael[/eluser]
Rúbia...

First off all, it's NOT a good pratice to define the path as a url (www.something). Try to figure out the real path "/public, /something"

- How your view call the controller?
- $arquivoImg = '...' is just an example, right?

I had many problems with Upload Class, but all that was MY problems. (ok, somes aren't explicity in manual).

PS:
Vc é brazuca né? Já ouvi falar da Neotix. Fica em Sampa, não? Qualquer coisa me manda um mensagem. Já faz bastante tempo que trabalho com CodeIgniter, se precisar posso dar uma força [Tongue]
#5

[eluser]Rubiz'[/eluser]
Yes, I post a entire form in the controller, who sends information to another controller, that should upload my files :-\


PS: Rafael vou falar com vc por PM!!
#6

[eluser]Rubiz'[/eluser]
A friend of mine told me that is not a MVC pratice to interact a controller with other controller.
And I was calling the upload wrong too.

Now, I have a method who calls another method (its working) who should upload the pictures.

Now I had a progress cause I have an error message: "Unable to load the requested language file: language/upload_lang.php"

What f$%&* is this error message talking about language???????????
#7

[eluser]Rubiz'[/eluser]
I think this is a "lost" case, cause my input actually is an array, and I cant set its name to my do_upload :-(
So I'll be trying change it... thanx somehow!
#8

[eluser]Rubiz'[/eluser]
Should I change Upload function to receive an array instead of a string?




Theme © iAndrew 2016 - Forum software by © MyBB