Welcome Guest, Not a member yet? Register   Sign In
"The upload path does not appear to be valid" (PULLING MY HAIR OUT !!!!) [SOLVED]
#11

[eluser]Christoph Rumpel[/eluser]
In my case it is not working with the period. It only works like that:

$config['upload_path'] = '/Applications/MAMP/htdocs/gallery/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';

$this->upload->initialize($config);

Still dont know why...
#12

[eluser]Mohammad Rashidi[/eluser]
[quote author="crumpel" date="1304786762"]In my case it is not working with the period. It only works like that:

$config['upload_path'] = '/Applications/MAMP/htdocs/gallery/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';

$this->upload->initialize($config);

Still dont know why...[/quote]
you just need to specify the upload pach, according to your CI root.
Code:
$config['upload_path'] = './gallery/';

whit this line of code, you mean that the images must be uploaded to a folder named "gallery" in your root, where you "index.php" is.

pay attention for this lines after your above code:
Code:
$this->load->library('upload', $config);
$this->upload->do_upload();
#13

[eluser]Christoph Rumpel[/eluser]
I tried $config['upload_path'] = './gallery/'; too. (gallery is my folder on MAMP/htdocs/ where alle my ci files are inside.
I do not understand how path works in CI.

I have a resize function with:

$config['source_image'] = 'mypic.png';

and this is working. (http://localhost:8888/gallery/mypic.png)
This would mean the root is inside ...gallery/

Still dont get why it does not work with the upload_path without "$this->upload->initialize($config);"

Thx for the help
#14

[eluser]Mohammad Rashidi[/eluser]
please let us now what are the errors via this line of code:
Code:
print_r($this->upload->display_errors());

your root is where your index.php is.
#15

[eluser]Christoph Rumpel[/eluser]
Code:
if ( ! $this->upload->do_upload())
        {
            print_r($this->upload->display_errors());
            
        }

This is how i implemented it.
Result just: "The upload path does not appear to be valid."
greets
#16

[eluser]Mohammad Rashidi[/eluser]
it is part of my recent project:
Code:
$config['upload_path'] = './test/';
        $config['allowed_types'] = 'jpg|png';
        $config['max_size']    = '100';
        $config['max_width']  = '236';
        $config['max_height']  = '315';
        $config['encrypt_name'] = TRUE;
        
    $this->load->library('upload', $config);
        $this->upload->initialize($config);
        $field_name = "userfile";
        
    if($this->upload->do_upload("userfile")){
            
        $uploaded_image = $this->upload->data();
        print_r($uploaded_image);

    }

feel free to use these lines of code.

please create a folder named 'test' in your CI root. also please ensure your field name & id is 'userfile'.
#17

[eluser]Christoph Rumpel[/eluser]
Hi, thx Mohammad, but i solved it 2 hours ago and forget to submit my post :-)
Here it is=)

now it also works with the period and the folder. Dont ask me why. Additionally i am using this extension library for more options in resizing:
MY Image lib Extension

This is no how it works for me, maybe this code could be of use fore someone else.

Code:
function do_upload()
    {
    // Upload- und resizefunktion
        // Test des Pfades
        //var_dump(is_dir('/Applications/MAMP/htdocs/gallery/'));
        //var_dump($_SERVER['SCRIPT_FILENAME']);  
        $config['upload_path'] = './assets/img/uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '200';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
        
        //dadurch klappt der pfad (initialsize)
        $this->upload->initialize($config);
        $this->load->library('upload', $config);

        if ( ! $this->upload->do_upload())
        {
        // Wenn der Upload NICHT funktioniert
                
            $data['upload_data'] =  $this->upload->display_errors();
            $data['title'] = 'Upload';
            $data['view'] = 'image/upload_v';
            $this->load->view('template',$data);
        }
        else
        {
        // Wenn der Upload funktioniert
            
            //$data für Weitergabe an sucess_view
            $data['upload_data'] = $this->upload->data();
            
            //infos über das upgeloadete file
            $data_upload_info = $this->upload->data();
            
            $this->load->library('image_lib', $config);
            
            $config['image_library'] = 'gd2';
            $config['source_image'] = $data_upload_info['full_path'];
            $config['create_thumb'] = TRUE;
            $config['maintain_ratio'] = TRUE;
            $config['width'] = 75;
            $config['height'] = 50;
            $config['ar_width'] = 75; //new config option
            $config['ar_height'] = 50; //new config option
            $config['new_image'] = './assets/img/thumbs/'.$data_upload_info['raw_name'].'_thumb.jpg';
        
            
            $this->image_lib->initialize($config);
            //ist eine zusätzliche library für image resize
            $this->image_lib->adaptive_resize();
            
            if ( ! $this->image_lib->adaptive_resize())
            {
                    echo $this->image_lib->display_errors();
            }
            else
            {
                //$this->load->view('image/upload_success_v', $data);
                $data['title'] = 'Upload';
                $data['view'] = 'image/upload_success_v';
                $this->load->view('template',$data);
            }
                
                
        }
            

            
    }
#18

[eluser]Mohammad Rashidi[/eluser]
congratulate Big Grin

crumpel, i was trying to resize my images, but it does not! GD2 is enabled, i have WAMP. have you ever had any problem with resizing?
#19

[eluser]Christoph Rumpel[/eluser]
I tried it today the first time, but it works for me. Do you get any errors? greets
#20

[eluser]Mohammad Rashidi[/eluser]
No, nothing! nor errors & actions!




Theme © iAndrew 2016 - Forum software by © MyBB