Welcome Guest, Not a member yet? Register   Sign In
Max file upload size
#1

[eluser]mvdg27[/eluser]
Hi guys,

I'm running into some problems with uploading large file through the upload class. If I select a small jpeg image everything works fine. But as soon as my file goes above 8MB it fails and returns "You did not select a file to upload."

Ok. So I checked my phpinfo and indeed te max file upload size is set to 8mb. However in the controller that contains my upload function, I've inserted an ini_set

Code:
ini_set('upload_max_filesize', '32M');
ini_set('max_execution_time', '600');

class Files extends Controller {

    // ..

    function upload_file() {
    
        // ..

        if(!$upload_erors = $this->general_model->upload_file($target_folder, $file, $allowed)) {                    
            $o['success'] = true;
            $o['message'] = $this->lang->line('file_uploaded');
        }
        else {
            $o['message'] = $upload_errors;
            $o['success'] = false;    
        }

        print json_encode($o);
    }

    // ..
}

And the code in my model is quite straightforward:

Code:
function upload_file($target_folder, $file, $allowed) {
                        
    $config['upload_path'] = $target_folder;
    $config['allowed_types'] = $allowed;
    $this->load->library('upload', $config);
    $this->upload->initialize($config);
        
    $this->upload->do_upload($file);
        
    return $this->upload->display_errors();

}

Any ideas on how to make my upload work with larger files as well?

Thanks in advance!
#2

[eluser]Zeeshan Rasool[/eluser]
did you put a die and print the file name that is being uploaded? Is file name has value
Also print all variables one by one

Code:
function upload_file($target_folder, $file, $allowed) {
    // Like this
    echo $file;
    die();
    $config['upload_path'] = $target_folder;
    $config['allowed_types'] = $allowed;
    $this->load->library('upload', $config);
    $this->upload->initialize($config);
        
    $this->upload->do_upload($file);
        
    return $this->upload->display_errors();

}
#3

[eluser]mvdg27[/eluser]
Yes .. if I print out $file, it prints the string 'file', which corresponds with the name of the upload field.

The $_FILES array however appears to be empty, when I do:

Code:
print_r($_FILES)

Guess, that's where the problem really lies.

Michiel
#4

[eluser]bigtony[/eluser]
Deleted (didn't read OP properly - my bad).
#5

[eluser]mvdg27[/eluser]
I have already checked that one. It's set to 8mb, like I described in my first post.

I don't really feel like changing the php.ini for all users/ all pages. Just for this specific controller, where I expect to receive files over 8mb. That's why I used the ini_set method.

Any reason why that wouldn't work?

Michiel
#6

[eluser]Zeeshan Rasool[/eluser]
[quote author="mvdg27" date="1248366919"]Yes .. if I print out $file, it prints the string 'file', which corresponds with the name of the upload field.

The $_FILES array however appears to be empty, when I do:

Code:
print_r($_FILES)

Guess, that's where the problem really lies.

Michiel[/quote]

check like this .. what it prints? its should be some integer value for file size.
Also did it works with small size file? I mean did it create problem with only large size?

Code:
print_r($_FILES[$file]['size'];)
#7

[eluser]coolgeek[/eluser]
I had a similar problem trying to reset session.gc_maxlifetime on a shared hosting environment. The solution was to maintain my own copy of php.ini

Here is how it's done on Dreamhost

http://wiki.dreamhost.com/PHP.ini#Custom...gle_domain
#8

[eluser]mvdg27[/eluser]
Hi guys, here's an update:

In the end I managed to fix it by adjusting the max_post_size variable in my php.ini as well. Now it's working fine, except that I wasn't able to set these values through ini_set().

So for now problem solved ..

Cheers, Michiel
#9

[eluser]mvdg27[/eluser]
Sorry .. duplicate message, not patient enough while submitting, I guess Smile
#10

[eluser]renownedmedia[/eluser]
Using ini_set('upload_max_filesize', '***') will not work because the upload is intercepted and ignored by Apache even before it hits PHP. An annoying thing for those of us using shared hosting without php.ini access!




Theme © iAndrew 2016 - Forum software by © MyBB