Skip Navigation

[Resolved] Cannot submit CRED form with file or image field

This thread is resolved. Here is a description of the problem and solution.

Problem:

Create a form where users can submit content with files and/or images, Files and images are uploaded successfully, but the form failed to submit, along with "You cannot upload a file of this type" and "You can only upload a image file" for each file and image fields.

Solution:

It is a compatibility problem, see details here:

https://toolset.com/forums/topic/cannot-submit-cred-form-with-file-or-image-field/#post-1225558

Relevant Documentation:

This support ticket is created 5 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 10 replies, has 3 voices.

Last updated by haryonoS 5 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#1220736
dummy.PNG

I am trying to: create a form where users can submit content with files and/or images

Link to a page where the issue can be seen: hidden link

I expected to see: form submitted successfully, along with files and images

Instead, I got: Files and images are uploaded successfully, but the form failed to submit, along with "You cannot upload a file of this type" and "You can only upload a image file" for each file and image fields.

#1220827

I can upload Image and Files fine on your Form, but when pressing submit, it tells me "You cannot upload a file of this type" unexpectedly - I also was not able to upload a simple .jpg image - and it threw this error: "You can only upload a image file"

This is however not expected nor happening locally.
I think it has to do with your server or WordPress settings.

It might as well be due to any other plugin, or theme. Or, even a Toolset Access setting that I am not aware of your usage of.

The error strings come from Toolset Form's Core Code and are thrown when the uploaded file type is invalid.
It should default to WordPress allowed extensions.
https://codex.wordpress.org/Function_Reference/get_allowed_mime_types
Unless you modified this, it should allow a whole set of file types, see above.

I could think of a few reasons:
- you restricted that list with custom code or another plugin or theme
- some other plugin or theme is simply breaking the Forms Upload validation
(you can check by disabling other plugins)
- you added some Toolset Forms validation to the Form
- there is a server issue

If you cannot spot the reason with the above hints, please try this:
- replicate your site on another server (local or another provider)
- test
- if still happening, please send me a duplicate https://toolset.com/faq/provide-supporters-copy-site/
- if solved, please contact your Server host to solve this issue

I hope this helps as a start.

#1221359

Thank you, Beda.

I have done the following but problems still exists.
- disable all non-toolset plugins
- check custom codes and toolset form validations for possible file type restrictions which I did not find any

There are no server modifications as far as I know. Forms used to worked but now they don't.

Will it help if I give you admin access to the site? You can also check my custom codes from there.

#1221436

1. Forms used to worked but now they don't

==> Do you recall since when?
This can be crucial to replicate or fix the issue as well.

2. I will need a copy of that site, possibly already with the 3rd party plugins disabled or removed.

3. Then, I can debug this locally (as that will require taking the site apart to see if I can replicate it on a clean install)

Thank you for understanding!

#1223701
wp-php.PNG

I cannot recall when this started to happen.

Before I provide the copy of the site, does it has anything to do with the PHP version?

I see WordPress' recommendation to upgrade PHP on the dashboard.

This the output of php -v from the terminal

$ php -v
PHP 5.5.9-1ubuntu4.14 (cli) (built: Oct 28 2015 01:34:46)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

#1223785

Hello,

According to our document, PHP 5.5.9 should not be a problem
https://toolset.com/toolset-requirements/
PHP 5.3 and above (including PHP 7).

Did you get any PHP/JS error logs?
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/

And if you need more assistance for it, please provide the duplicator package of your website, also include the files you are going to upload, I need to test and debug it in my localhost, thanks

#1224393

Thanks for the details, I am downloading files, will update here if there is anything found

#1224820

Thanks for the details, I assume we are talking about the Toolset post form "Dummy Form", I have tested it in my localhost.

Here are what I found:
1) The problem is in your theme "StarDev ERP", you can try to switch to parent theme "Astra", and test again.

2) According to WordPress document:
https://wordpress.org/news/2019/04/minimum-php-version-update/
WordPress will now require a minimum of PHP 5.6.20.

I suggest you upgrade your webserver PHP version to upgrade 5.6 or above

#1225555

After further checking, I found out that the problem is caused by these specific lines in

inc/styles.php

where I try to include my child theme's css.

wp_enqueue_style( 'stardev-erp-theme-css',
    get_stylesheet_directory_uri() . '/style.css',
    array( $parent_style ),
    CHILD_THEME_VERSION,
    'all'
);

Commenting those lines will fix it, but I will not have my child theme styles loaded. I thought it has anything to do with the CSS, but commenting everything in the style.css still does not fix it.

UPDATE:

It *has* something to do with the CSS. I have the following style in my child theme's style that causes the problem. Commenting these lines fixes the problem.

.form-control {
	display: inline-block !important;
	width: auto;
}

Can you explain why it effects CRED form submission's functionality?

#1225558

Thanks for the details, please try these:
1) Remove/comment your custom CSS codes, test the post form in front-end:
hidden link

2) in field "Dummy File", upload a file, you should be able to see the file field is being hidden.
But your custom CSS codes make it to keep on displaying.

display: inline-block !important;

It conducts the problem, Toolset form validation take those fields failed to validation.

#1225584

That explains it. My issue is resolved now. Thank you!