Jump to content

Module: Jquery File Upload


kongondo

Recommended Posts

As for your question about image replacement: I think it would be easiest to either extend FieldtypeFile or modify FieldtypeImage as a new module (and/or their related Inputfields - am not sure). What exactly are you after? I ask because I know there are some cool changes coming to the 'standard image field' and those might just meet your needs.

actually i'm only very eager about client side image resizing. i know that this is on the roadmap for 2016 but that can be everything between next blog post tomorrow and december ;) maybe you have some more details?

i'm getting offtopic here so i started a new thread in pub: https://processwire.com/talk/topic/12861-feature-wishlist-for-shortly-planned-developments/?p=116757

Link to comment
Share on other sites

Update: Jquery File Upload Version 0.0.3.

Changelog

  1. Fixed an issue that caused duplicates in image gallery
  2. Some minor enhancements
Glad to also announce that I've tested and can confirm that Jquery File Upload is compatible with ProcessWire 2.8.x and ProcessWire 3.x 
  • Like 3
Link to comment
Share on other sites

  • 2 months later...

@kongondo love the module, it's helped me get past a hurdle. One issue I'm encountering is uploading more diverse file types - zip and various Adobe types. Is this something that the module can support? If so, any ideas what I'm doing wrong?

I've added  allowedNonImageMimeTypes under the ajaxoptions('application/pdf', 'application/postscript', 'application/octet-stream', 'application/x-compressed', 'application/x-zip-compressed') and added the extensions to the acceptfiletypes under jfuoptions. The files show up, I get upload progress, and then I get the message:

Empty file upload result
 
Nothing shows up on the server. If I upload JPGs or PDFs - either on their own or at the same time as non-working files - they work just fine.
 
I'm on PW 3.0.42.
Link to comment
Share on other sites

@Chris Whissen,

Hmm. It means, then, that the reason they are not passing validation is because they are failing the PHP mime type tests. This is either because their mime types are unknown or the 'files are not what they seem' (aka faked files)':

  • Can you confirm you are passing the allowedNonImageMimeTypes to processJFUAjax()
  • If they don't contain any sensitive data, is it possible to PM a couple of those files getting rejected to help me debug this further?
Link to comment
Share on other sites

6 minutes ago, kongondo said:
  • Can you confirm you are passing the allowedNonImageMimeTypes to processJFUAjax()

Yes. I'm doing it like this:

'allowedNonImageMimeTypes' => array('application/pdf', 'application/postscript', 'application/octet-stream', 'application/x-compressed', 'application/x-zip-compressed'),
Quote
  • If they don't contain any sensitive data, is it possible to PM a couple of those files getting rejected to help me debug this further?

No problem. I'll have something to you in a moment. I personally created the Zip in Windows and the AI in Illustrator, so they shouldn't be fake. 

Link to comment
Share on other sites

No worries. Had just come to that conclusion just before your response. Actually, I am the idiot! I notice that 'acceptFileTypes' is not documented! Users shouldn't have to read the module code to know how to use it :o! When I get the time.....(ahem..). Yes, so what was happening is that good ol' WireUpload was rejecting those file extensions at this point. Glad you got it sorted and now thanks for the reminder that I'll need to update the docs :)

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

So, I'm stretching my knowledge here and can't quite figure out an issue. If I'm logged in to PW and go to front-end upload page, everything works fine.

If a guest attempts to upload a file, they get an "Internal Server Error."

I'm guessing it has something to do with the security, specifically(emphasis added):

On 1/28/2016 at 9:39 PM, kongondo said:

Server-side, no Ajax requests are honoured unless specifically set via configurable options server-side.

I'm not sure what I need to be doing for that though. I've tried to figure out on my own, but am not having much luck. Can anyone point me towards how to make this work? (Assuming there's no other obvious reason for the error.)

EDIT: Just to narrow possibilities, I created a user with guest permissions. If logged in, uploads without issue. It's only an anonymous user that can't upload. Which is an essential function for this site. Am I overlooking something obvious?

Edited by Chris Whissen
clarification
Link to comment
Share on other sites

Okay, I managed to get it to work, but I'm not sure it's the best and safest way to do it. Ran Tracey Debugger and got "This request was aborted because it appears to be forged." error message. I did some research on that and disabled protectCSRF through config.php ($config->protectCSRF = false;). Now. anonymous uploads work fine.

I'm not sure if that's the right way to do it, but I'm also not sure this is the right post to be asking - that might be more a ProcessWire issue than this module.

Link to comment
Share on other sites

16 hours ago, Chris Whissen said:

If logged in, uploads without issue. It's only an anonymous user that can't upload

Guests should be able to upload. I am not sure what's happening in your case. Just to be sure, I've double checked in PW 2.7, 2.8 and 3. Guests (meaning frontend users not logged in [anonymous if you like]) can upload just fine.

16 hours ago, Chris Whissen said:

I'm not sure if that's the right way to do it, but I'm also not sure this is the right post to be asking - that might be more a ProcessWire issue than this module.

There's no issue with the module nor with ProcessWire (I believe) in this case :). There's something else going on in your install I suspect. Some setting or hook or similar?

  • Like 1
Link to comment
Share on other sites

I fixed the problem for me.  Letting you know because I think you have either a missing zero or typo in the module. It reads:

'maxFileSize' => 200000000,// 2GB

Assuming that's bytes, that equals 200MB, not 2GB - also assuming I can still do math. I added a zero and pasted it into my jfuoptions array and everything works for me. 

  • Like 2
Link to comment
Share on other sites

12 hours ago, Chris Whissen said:

I think you have either a missing zero or typo in the module

Nice catch Chris. You are right. I was missing one Zero. Corrected in version 5.

Update: Jquery File Upload Version 0.0.5.

Changelog

  1. Fixed a typo in the default setting of maxFileSize. Thanks @Chris Whissen

 

 

  • Like 1
Link to comment
Share on other sites

  • 6 months later...
  • 1 month later...
  • 1 month later...
  • 3 weeks later...

Hello @kongondo I really like the module! I just have a problem with adding eventlisteners, nothing I tried so far seemed to work, are the $('#fileupload').bind functions from the jquery file upload-documentation the right ones?

Currently I hacked my code into the downloadTemplate-function of the jqueryfileupload.js, accessing the other events would be killer though :)

 

 

Link to comment
Share on other sites

Hi @huhabab,

Welcome to the forums. Glad you find the module useful.

1 hour ago, huhabab said:

I just have a problem with adding eventlisteners, nothing I tried so far seemed to work, are the $('#fileupload').bind functions from the jquery file upload-documentation the right ones?

Yes, they are. What events are you missing? Have you seen the ones listed in the docs under Callback Options ? I have tested a couple and they work as advertised. The Callbacks section of the API Docs is also a good read in this regard. Maybe you can show us some code?

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...