Welcome Guest, Not a member yet? Register   Sign In
Multi File Upload with CI
#1

[eluser]psychomarine[/eluser]
I solved my own problem,

Moderators, Kindly please Remove this thread.

My Apologizes.
#2

[eluser]nEJC[/eluser]
Ah, why remove anything?

Instead of removing the question - why don't you also provide the answer/solution?
Maybe someone else could learn from this ...

Quoting your original question:
Quote:...
I am using javascript to append a new field to the view after each download is created.
Normal multi file uploads, as I have read on these forums, seem to make you already know the number of fields that you have added for uploads.

This shouldn’t be much of an issue, as with a little custom php I should be able to loop through all these, count them, and generate these uploads using a foreach statement.

I have failed.

I was really hoping that someone else had this issue and fixed it, or even wrote a simple library to handle it.

I dont need the library, but I could really use some tips on how I could accomplish this.

Just a recap: Using javascript, Each time a user selects a file to upload, it will clear the download select, ready for selecting another file, and append my fields with userfile[], and yep, as an array, BUT I cant seem to get the single upload script built in, NOR the multi file upload library that I found on these forums and highly recommended by several others around here.
...

Hope you see the value in providing the info ... Wink
#3

[eluser]psychomarine[/eluser]
because I didn't want to double post. There is already a thread on the same problem that I missed before and accidentally came upon it.

That made my thread, basically a duplicate thread, which is kinda pointless.

Hope you understand.
#4

[eluser]NateL[/eluser]
So where's that thread? It's still useful info.
#5

[eluser]psychomarine[/eluser]
the solution was discovered on this page. Sort of unrelated of course but I discovered my problem with this.
http://ellislab.com/forums/viewthread/121434/


Now, Ill go ahead and make this easy for everyone.

The problem is, most of the tutorials and doc's tell you to do this:

Code:
public function do_upload()
    {
        $config['upload_path'] = './uploads/files/';
        $config['allowed_types'] = 'jpg|png|gif';
        $config['max_size']    = '1000';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
        
        $this->load->library('upload', $config);
...and so on...

Well, out of habbit, me and many other people, like to load our things in the __construct() and keep it uniform.

I however did not realize, as many others that by doing:
Code:
public function __construct()
    {
        parent::Controller();    

        $this->load->library('upload');
        $this->load->library('form_validation');
    }

messes up when you call it a 2nd time, as shown in the first example.


Now I can only assume that codeigniter has implemented some sort of singleton method, which is smart I might add.

For those who dont know, a singleton basically allows one instance of a class to run preventing a 2nd instance from initializing. (basically because it goes alot deeper than that in some cases)


Now, what was happening was that the __contruct was loading the upload class first, ignoring any config I tried to feed into it later on.

Now, removing the initial loading of the upload class solved my issue.

There is also a second fix, as referenced in the user guide, for those who like to load everything needed in the __construct:
Code:
// Alternately you can set preferences by calling the initialize function. Useful if you auto-load the class:
$this->upload->initialize($config);

Hope this helps anyone who has issues. Its a good starting point when you think everything is correct and it just wont work properly.

It can be annoying because we KNOW it works, else theres low chances on them releasing it to the public if it doesnt work at all.

in closing, seems to be a case of "pebkac"


Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB