Welcome Guest, Not a member yet? Register   Sign In
Multiple Upload - code review
#1

Hi all,

I'm trying to create an extension on the Upload library in order to upload multiple files at once. This is my repo in order to check the code.

The main idea I have in my mind is that the extension will try to upload all the files, and then will return an array of all files that failed to upload with each error, for instance:

Code:
- File: some_text.txt Error: The file has invalid format
- File: image.jpg Error: The files width or height is too big
etc

and the files that uploaded successfully ( the CI upload data() ).
Reply
#2

(01-08-2015, 12:07 AM)Lykos22 Wrote: Hi all,

I'm trying to create an extension on the Upload library in order to upload multiple files at once. This is my repo in order to check the code.

The main idea I have in my mind is that the extension will try to upload all the files, and then will return an array of all files that failed to upload with each error, for instance:


Code:
- File: some_text.txt Error: The file has invalid format
- File: image.jpg Error: The files width or height is too big
etc

and the files that uploaded successfully ( the CI upload data() ).

Hi Lykos22,

Avenirer has a good tutorial on multiple uploads with CI that may answer your query here.

It also documents the whole procedure which may be able to answer any other questions you have with writing your code Smile
Jamie Bond
Full time International Development undergraduate.
Part time website developer.
Reply
#3

(This post was last modified: 01-08-2015, 03:10 AM by Lykos22.)

(01-08-2015, 02:42 AM)Jamie Wrote: Hi Lykos22,

Avenirer has a good tutorial on multiple uploads with CI that may answer your query here.

It also documents the whole procedure which may be able to answer any other questions you have with writing your code Smile

@Jamie Yes I've seen this tutorial, its seems really good.

I have tested the code in my repo and works fine, however I'd like to get some feedback and from you guys whether its ok or not, so all opinions are welcome. Smile
Reply
#4

Nicely done, @Lykos22. But did you try to extend the do_upload() method? That would be interesting. Give it a try. I will also look into it.  Blush
Reply
#5

(01-08-2015, 07:53 AM)Avenirer Wrote: Nicely done, @Lykos22. But did you try to extend the do_upload() method? That would be interesting. Give it a try. I will also look into it.  Blush

Thanks for the reply! I really appreciate all feedback you give me.

@Avenirer To answer your question, in the beginning I thought to extend the do_upload() method as you said, but I finally decided to keep it separate, as I wanted also to keep the default functionality too, just in case needed in some other cases.

However if you take a closer look in my do_multi_upload() method, I check whether there's one or more files to upload. If there's just one the function falls back to the default do_upload() method. In addition when doing multi uploading my do_multi_upload() method uses CI do_upload() method.
Reply
#6

Hello @Lykos22

Please take a look at the MY_Upload that I've made: https://github.com/avenirer/MY_Upload. It does the same things that you've wanted, but uses the same methods as the CI_Upload. If a single file is uploaded, everything is corectly done by the CI_Upload. I will have to work on it some more so that, if I add another parameter in the config array that initializes the library, it will allow the user to choose the course of action on multiple upload (three options):

1. halt uploading of files on first error, and return the data and the errors
2. try uploading all and then return the data and the errors
3. don't upload anything if an error was encountered.

What do you think?
Reply
#7

(01-10-2015, 02:37 PM)Avenirer Wrote: 1. halt uploading of files on first error, and return the data and the errors
2. try uploading all and then return the data and the errors
3. don't upload anything if an error was encountered.

What do you think?

Good job @Avenirer ! I'll wait to see these 3 functionalities you said too, I think this will make it more robust. I 'll also try to do the same thing in my extension too, and update my code.
Reply
#8

Well... Here you go! Meet MY_Upload: http://avenir.ro/my_upload-extension-all...e-uploads/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB