PWaddict Posted September 7, 2020 Share Posted September 7, 2020 I'm trying to set maximum image files per upload with the following hook: $wire->addHookBefore('InputfieldImage::render', function(HookEvent $event) { $inputfield = $event->object; $inputfield->setMaxFiles(20); }); but when I go to edit a page with Images fields I'm getting the following error: ProcessWire: ProcessPageEdit: Method InputfieldImage::setMaxFiles does not exist or is not callable in this context Link to comment Share on other sites More sharing options...
Zeka Posted September 7, 2020 Share Posted September 7, 2020 @PWaddict Try to use $inputfield->set('maxFiles', 20); Link to comment Share on other sites More sharing options...
PWaddict Posted September 7, 2020 Author Share Posted September 7, 2020 3 minutes ago, Zeka said: @PWaddict Try to use $inputfield->set('maxFiles', 20); This just sets field to accept ONLY 20 images. What I'm looking for is let the editor upload 20 images per upload. If he wants to upload 50 images I don't want to let him upload them all at once. Link to comment Share on other sites More sharing options...
PWaddict Posted September 7, 2020 Author Share Posted September 7, 2020 Unless maxFiles & setMaxFiles are actually the same? I've read somewhere that setMaxFiles is max allowed files per upload. Link to comment Share on other sites More sharing options...
bernhard Posted September 7, 2020 Share Posted September 7, 2020 1 hour ago, PWaddict said: What I'm looking for is let the editor upload 20 images per upload. If he wants to upload 50 images I don't want to let him upload them all at once. Sorry, I don't understand what you are trying to do ? 20 + 20 + 10 would work? What is the reason for that request? What is "one upload"? I think you need to be more precise to get better answers. Link to comment Share on other sites More sharing options...
PWaddict Posted September 7, 2020 Author Share Posted September 7, 2020 46 minutes ago, bernhard said: Sorry, I don't understand what you are trying to do ? 20 + 20 + 10 would work? What is the reason for that request? What is "one upload"? I think you need to be more precise to get better answers. My php default shared server settings have max_file_uploads = 20 so I would like to limit to 20 in ProcessWire too cause if I upload for example 30 images at once only the 20 will be uploaded. The other 10 will look like they're uploading forever and this is confusing for the editors. So, is it possible to limit it to 20 in ProcessWire or should I increase the number of max_file_uploads? Also, If I increase it wouldn't be bad for the server performance? Like with "setMaxFilesize" you're getting a warning on ProcessWire that you're not allowed for example to upload a file with size more than what you've set in "setMaxFilesize", I wanna do the same thing for the maximum files the editor can upload at once. I wanna let him upload max 20 and when those 20 uploaded he should be able to upload 20 max more and so on. Link to comment Share on other sites More sharing options...
PWaddict Posted September 8, 2020 Author Share Posted September 8, 2020 It seems that setMaxFiles is actually used for the maxFiles value (Maximum files allowed) under the Details tab of the file/image field. Link to comment Share on other sites More sharing options...
PWaddict Posted September 8, 2020 Author Share Posted September 8, 2020 Ok something else is going on. On localhost where PHP has max_file_uploads = 20 too (same as live server) I tried to upload 22 images at once and it worked fine. On live server when I tried to upload the same 22 images I got 13 identical errors in chrome console and 13 images stuck at "uploading" forever... Failed to load resource: net::ERR_HTTP2_PROTOCOL_ERROR Link to comment Share on other sites More sharing options...
PWaddict Posted September 8, 2020 Author Share Posted September 8, 2020 Please delete this topic. Link to comment Share on other sites More sharing options...
LostKobrakai Posted September 8, 2020 Share Posted September 8, 2020 3 hours ago, PWaddict said: On localhost where PHP has max_file_uploads = 20 too (same as live server) I tried to upload 22 images at once and it worked fine. That's because the file input field uses ajax requests for the files. So each request only holds a single file. 1 Link to comment Share on other sites More sharing options...
PWaddict Posted September 8, 2020 Author Share Posted September 8, 2020 Now, I'm getting more errors besides the one I mention above. You can delete this topic and if I can't figured out the problem I will create a new proper topic with all the details. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now