This works beautifully, except for when the filefield is limited to only one item. I'm presuming that plupload can still handle single file uploads nicely, and will apply all it's benefits (chunking, progress etc.) to a single item upload. I'm also presuming that this issue can be resolved here, rather than in the filefield sources module.

Thanks

Simon

Comments

atlea’s picture

Assigned: Unassigned » atlea

Hum. I will have to look into limiting the number or files. I'll add this to the todo!

burgs’s picture

Atlea, you are a legend. It looks like the plupload team themselves don't really have an elegant, documented solution for this, so that might be a small issue. Let me know where I can help.

osman’s picture

Status: Active » Needs review
StatusFileSize
new5.09 KB

I believe I have a solution. Please review and test it.

Edit: There are some proper labeling issues, and typos, etc. But the functionality should be ready for reviewing.

adam_b’s picture

Works well for me - many thanks :)

atlea’s picture

Nice one! I'll try to have a new dev that includes this functionallity over the weekend. :)

Tsubo’s picture

Has patch #3 been committed yet?

trebol’s picture

I cant apply the patch by atlea, because the code of the patch its different of the code i see in my module. i got the last version installed, and this option is not added.

Any valid script to enable single file upload?

antipode’s picture

great - I tried something myself but was not aware of the $element['#attached']['js'][].

however - I still get the option to add more files when uploading. I thought this patch will allow only for 1 file to select and upload.

osman’s picture

Here is an updated patch.

If cardinality is set to "1", Plupload is forced to select only one file at a time in "file select" dialog windows by adding multi_selection: FALSE and multiple_queues: FALSE settings to plupload object.

If cardinality is set to anything but unlimited; number of the files in the queue is checked on "QueueChanged" event.
Files exceeding the limit are removed from the queue instantly. Meanwhile, Add files link/button is kept hidden when the number of the files in the queue matches the (cardinality) limit.

I tested this with different cardinality settings. But please do test it yourselves as well.

osman’s picture

Forgot to mention; with this patch cardinality value is passed to plupload object as a setting. So it would be available at all times.
Later it is used in plupload.js as pluploadSettings.cardinality in QueueChanged event.

muschpusch’s picture

Status: Needs review » Reviewed & tested by the community

ok this patch is awesome because of two reasons:

- single file upload (my usecase i use plupload because of chunking large files)
- cardinality is checked before uploading on plupload side

muschpusch’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new4.64 KB

ok just some little adjustments to the label

atlea’s picture

Status: Needs review » Fixed

Patch seems to work nicely. I have added it to the dev-version.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.