Skip Navigation

[Resolved] Cred form, upload file with disabled AJAX progress bar not working

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

Problem:

The issue here is that the user used the following hook to disable the ajax upload progress bar for images.

add_filter("cred_file_upload_disable_progress_bar", "disable_progress_bar");
function disable_progress_bar($val) {
    return true;
}

But this caused his images to stop uploading.

Solution:
We actually have an errata for this and can be seen in the link below.
https://toolset.com/errata/disabling-ajax-upload-in-cred-forms-stops-forms-from-uploading-data-altogether/

This support ticket is created 6 years, 1 month 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 11 replies, has 2 voices.

Last updated by Shane 6 years, 1 month ago.

Assisted by: Shane.

Author
Posts
#612822

Hello,

I am trying to upload a file via CRED form with disabled ajax progress bar.
I have following piece of code in my function.php

add_filter("cred_file_upload_disable_progress_bar", "disable_progress_bar");
function disable_progress_bar($val) {
    return true;
}

Its copied from the example here https://toolset.com/documentation/programmer-reference/cred-api/#cred_file_upload_disable_progress_bar

When I click on submit button, I got following error message "Please enter a valid URL address pointing to the file"

hidden link

I have latest WP, Types and default twentyseventeen theme. All other plugins are disabled as well.

Thanks for help

#612868

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Vladimir,

Thank you for contacting our support forum.

Yes the Disable progress bar does disable the AJAX upload for the form. This is because the Progress bar is to show the upload progress for the Image upload so they are essentially linked.

This reverts the form to using the traditional method of uploading the image when the form is submitted.

However it seems that you are having some issues with this as your form gives an invalid URL for the image correct?

Please let me know.
Thanks,
Shane

#612874

Hello,
my goal is disable ajax file upload and use old method to upload file.

In cred form settings is unchecked "AJAX submission" and in functions.php is piece of code mentioned in my first post.

File field is custom post field added in Types. Its not only for image, but for general attachment. It does not matter what kind of file I'm trying to upload, it alway gives me an error "Please enter a valid URL address pointing to the file"

Thanks

#612910

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Vladimir,

Would you mind providing me with access to the site so that I can have a look at this for you ?

The private fields will be enabled for your next response.

Thanks,
Shane

#613037

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Vladimir,

I believe this could be a server permissions issue.

However could you try recreating the CRED form and let me know if this issue still remains ?

Also please check your uploads folder in wp-content folder to ensure the correct permissions are there as stipulated by the document below
https://codex.wordpress.org/Changing_File_Permissions

Please let me know if this helps.
Thanks,
Shane

#613232

Hello,
I don't think is a permission related. We are using suphp on our server, so script are runned under same account ad whole home dir is. And the ajax version works fine.

But here is, what we find, mabye it helps you:
The situation:
Form created in CRED has only two file filse created with shortcode:
[cred_field field='extended-abstract' post='paper' value='' urlparam='']
Ajax submission in Other setting is unxhecked (but it does not matter)
The is function added to functions.php that disables ajax upload:
add_filter("cred_file_upload_disable_progress_bar", "disable_progress_bar");
function disable_progress_bar($val) {
return true;
}

And here is the point. When function is removed and upload works works with Ajax, there is hidden input field cerated with file input:
<input type="hidden" id="wpcf-extended-abstract_hidden" name="wpcf-extended-abstract" value="" class="js-wpv-credfile-hidden wpt-form-hidden form-hidden" data-wpt-type="file" disabled="disabled" data-wpt-id="cred_form_369_1_wpcf-extended-abstract_hidden" data-wpt-name="wpcf-extended-abstract">
When file is selected, its uploaded to server and when its done, the files url (whole URL) is added as value to this field.
<input type="hidden" id="wpcf-extended-abstract_hidden" name="wpcf-extended-abstract" value="hidden link" class="js-wpv-credfile-hidden wpt-form-hidden form-hidden" data-wpt-type="file" data-wpt-id="cred_form_369_1_wpcf-extended-abstract_hidden" data-wpt-name="wpcf-extended-abstract">
If I finaly submit form, file is added to post sucesfully.

But when I disable Ajax, same field has been created, again with empty value. But when I select file, no ajax has been runned so the field remains empty. When I submit the form, it reloads the same page but with error "Please enter a valid URL address pointing to the file."

The hidden field now looks like this:
<input type="hidden" id="wpcf-extended-abstract_hidden" name="wpcf-extended-abstract" value="filename.jpg" class="js-wpv-credfile-hidden wpt-form-hidden form-hidden" data-wpt-type="file" data-wpt-id="cred_form_369_1_wpcf-extended-abstract_hidden" data-wpt-name="wpcf-extended-abstract">

You can see its value changed to file name, but when I try to submit form, it returns same error again. But when I edit the value in browsers developer tool and add the whole url in it and not just file name, form can be submitted successfully.

The last thing what I found is the javascript error in console, which goes form validation. When form is showed (firstly, before any submission), I click on file input to select file and after it, when I blur the input, this has been added to console in browser:

Uncaught TypeError: Cannot read property 'call' of undefined
at $.validator.check (jquery.validate.js?ver=0.1.2:528)
at $.validator.element (jquery.validate.js?ver=0.1.2:349)
at $.validator.onfocusout (jquery.validate.js?ver=0.1.2:232)
at a.fn.init.delegate (jquery.validate.js?ver=0.1.2:313)
at HTMLFormElement.<anonymous> (jquery.validate.js?ver=0.1.2:1152)
at HTMLFormElement.dispatch (jquery.js?ver=1.12.4:3)
at HTMLFormElement.r.handle (jquery.js?ver=1.12.4:3)
at Object.trigger (jquery.js?ver=1.12.4:3)
at Object.a.event.trigger (jquery-migrate.min.js?ver=1.4.1:2)
at Object.simulate (jquery.js?ver=1.12.4:3)

Thanks

#613515

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Vladimir,

Would you mind if I took a duplicator package from this website to test on my local host to ensure this isn't a server issue ?

Looking forward to hearing from you soon.

Thanks,
Shan

#613551

sure, test what ever you need. this is just a test site... so don't worry 🙂

#613787

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Thanks Vladimir, will report any findings.

#613805

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Vladimir,

It seems that we have discovered a bug here as this issue is clearly replicable of a fresh installation.

I'm going to report this to our development team but the current workaround I see is to just leave the ajax file upload enabled.

Thanks,
Shane

#616822

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Vladimir,

We have released an errata for this and should be able to resolve the issue.
https://toolset.com/errata/disabling-ajax-upload-in-cred-forms-stops-forms-from-uploading-data-altogether/

Please take a look at the link below and let me know if this helps.
Thanks,
Shane

#618654

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Vladimir,

Can you confirm ASAP if this has solved the issue for you ?

Thanks,
Shane

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.