kongondo

Module: Jquery File Upload

44 posts in this topic

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

Share this post


Link to post
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 
3 people like this

Share this post


Link to post
Share on other sites

Update: Jquery File Upload Version 0.0.4.

Changelog

  1. Fixed a small bug introduced during the last commit. This causes some images not to be displayed in image gallery.
1 person likes this

Share this post


Link to post
Share on other sites

@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.

Share this post


Link to post
Share on other sites

@kongondo thanks - I'm new to alot of this and just starting to figure it out. These forums and the modules have taught me alot!

I don't believe any of those apply - the server is running PHP 5.4+ on Linux. 

Share this post


Link to post
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?

Share this post


Link to post
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. 

Share this post


Link to post
Share on other sites

@kongondo I'm an idiot and thank you for your time and help. I reread the module a little closer and realized I need the acceptfiletypes twice - once for Ajax options and once for JFUoptions. I only had it once. Added that in and everything is working fine. Apologies for wasting your time, truly appreciate the help.

Share this post


Link to post
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 :)

1 person likes this

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

Share this post


Link to post
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?

1 person likes this

Share this post


Link to post
Share on other sites

Thanks for looking into it @kongondo. I have quite a few modules running, so there could be something in there making a mess of things. Another mystery to solve - at least that one can wait a bit. Appreciate the help and love the module!

Share this post


Link to post
Share on other sites
35 minutes ago, Chris Whissen said:

It says the file size limit is set at 2GB, but it appears to be set at 200MB. 

Check your PHP ini for these settings:

post_max_size
upload_max_filesize

Share this post


Link to post
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. 

2 people like this

Share this post


Link to post
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

 

 

1 person likes this

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By bernhard
      Hi,
      just stumbled over a little module that i built for my last project. it helped me to test performance of my rockdatatables module to generate 3000 random json datasets and i want to share it with you. maybe it saves some time for someone.
      https://gitlab.com/baumrock/RockDummyData/
      easy example:
      $rdd = $modules->get('RockDummyData'); for($i=0; $i<15; $i++) { // this has to be inside the for-loop to always get a new dummy $dummy = $rdd->getDummy(); echo date("d.m.Y H:i:s", $dummy->timestamp) . "<br>"; } more advanced:
      $json = new stdClass(); $json->data = array(); $rdd = $modules->get('RockDummyData'); for($i=0; $i<3000; $i++) { // this has to be inside the for-loop to always get a new dummy $dummy = $rdd->getDummy(); $obj = new stdClass(); $obj->name = $dummy->forename . ' ' . $dummy->surname; $obj->position = $dummy->job; $obj->office = $dummy->city; $obj->color = $dummy->color; $obj->start_date = new stdClass(); $obj->start_date->display = date('d.m.Y',$dummy->timestamp); $obj->start_date->sort = $dummy->timestamp; $obj->salary = rand(0,10000); $json->data[] = $obj; } echo json_encode($json); you have to store your random datasets on your own into the /data folder. there are several services for creating all kinds of random data on the web - if you know one service that allows sharing those datasets let me know and i can include common needed data into the module
    • By AndySh
      Hello!
      I need your assistance please. I purchased the module FormBuilder. Unfortunately, the module discontinued delivering customer submissions to e-mail box specified in the module settings. Direct mailing to the e-mail box works OK. The module settings stays the same and are correct, like "Send e-mail to administrator(s) is checked. The last version of FormBuilder 3.0 has been installed. Please advise how to resolve the issue becase I cannot get orders from customers anymore (((
    • By kixe
      As described in this post (https://processwire.com/talk/topic/8551-custom-urls-for-pages/?p=82742) the option 'Name Format Children' under the tab 'Family' in template settings doesn't work properly and also not as expected. I had a look inside the code and made some changes which are working properly, which offers much more options, more consistency and less code too.

      The result is the following. You have 3 Options for generating name and title, which could be combined in endless variations.
      Name is always derived from title, same like creating pages manually.
      type date: if function detects # character anywhere in the string, conversion will be: deletion of # and string will be used as format parameter for PHP date() function type field: if string is a fieldname of the parent page the value of this field will be used type string: if string doesn't fit to the 2 preceeding it will be taken as it is All parts (separated by comma) will be composed in the order of setting. You can use unlimited numbers of parts

      I made a pull request on github: https://github.com/ryancramerdesign/ProcessWire/pull/831

      Example screenshots

      Setting ...


      will result in


       
    • By kongondo
      FieldtypeRuntimeMarkup and InputfieldRuntimeMarkup
       
      Modules Directory: http://modules.processwire.com/modules/fieldtype-runtime-markup/
      GitHub: https://github.com/kongondo/FieldtypeRuntimeMarkup
       
      This module allows for custom markup to be dynamically (PHP) generated and output within a page's edit screen (in Admin).
       
      The value for the fieldtype is generated at runtime. No data is saved in the database. The accompanying InputfieldRuntimeMarkup is only used to render/display the markup in the page edit screen.
       
      The field's value is accessible from the ProcessWire API in the frontend like any other field, i.e. it has access to $page and $pages.
       
      The module was commissioned/sponsored by @Valan. Although there's certainly other ways to achieve what this module does, it offers a dynamic and flexible alternative to generating your own markup in a page's edit screen whilst also allowing access to that markup in the frontend. Thanks Valan!
       
      Warning/Consideration
      Although access to ProcessWire's Fields' admin pages is only available to Superusers, this Fieldtype will evaluate and run the custom PHP Code entered and saved in the field's settings (Details tab). Utmost care should therefore be taken in making sure your code does not perform any CRUD operations!! (unless of course that's intentional) The value for this fieldtype is generated at runtime and thus no data is stored in the database. This means that you cannot directly query a RuntimeMarkup field from $pages->find(). Usage and API
       
      Backend
      Enter your custom PHP snippet in the Details tab of your field (it is RECOMMENDED though that you use wireRenderFile() instead. See example below). Your code can be as simple or as complicated as you want as long as in the end you return a value that is not an array or an object or anything other than a string/integer.
       
      FieldtypeRuntimeMarkup has access to $page (the current page being edited/viewed) and $pages. 
       
      A very simple example.
      return 'Hello'; Simple example.
      return $page->title; Simple example with markup.
      return '<h2>' . $page->title . '</h2>'; Another simple example with markup.
      $out = '<h1>hello '; $out .= $page->title; $out .= '</h1>'; return $out; A more advanced example.
      $p = $pages->get('/about-us/')->child('sort=random'); return '<p>' . $p->title . '</p>'; An even more complex example.
      $str =''; if($page->name == 'about-us') { $p = $page->children->last(); $str = "<h2><a href='{$p->url}'>{$p->title}</a></h2>"; } else { $str = "<h2><a href='{$page->url}'>{$page->title}</a></h2>"; } return $str; Rather than type your code directly in the Details tab of the field, it is highly recommended that you placed all your code in an external file and call that file using the core wireRenderFile() method. Taking this approach means you will be able to edit your code in your favourite text editor. It also means you will be able to type more text without having to scroll. Editing the file is also easier than editing the field. To use this approach, simply do:
      return wireRenderFile('name-of-file');// file will be in /site/templates/ If using ProcessWire 3.x, you will need to use namespace as follows:
      return ProcessWire\wireRenderFile('name-of-file'); How to access the value of RuntimeMarkup in the frontend (our field is called 'runtime_markup')
       
      Access the field on the current page (just like any other field)
      echo $page->runtime_markup; Access the field on another page
      echo $pages->get('/about-us/')->runtime_markup; Screenshots
       
      Backend
       

       

       
      Frontend