Skip Navigation

[Resolved] Input Type File

This support ticket is created 5 years, 2 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 3 replies, has 2 voices.

Last updated by Luo Yang 5 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#1379343

I have a cred form with the following div where a user is able to upload an image using the standard wordpress upload method. The image in the below scenario gets assigned to the standard wordpress field: featured image.

	<div class="form-group">
		<label>Scorecard</label>
      	[cred_field field="_featured_image" output="bootstrap"]
	</div>

I want to modify this so it's simpler for users to upload a file and so for this; I'm wanting to modify it to the following:-

<input type="file" id="_featured_image" name="_featured_image" field="_featured_image" accept="image/jpeg,image/png,jpg|png">

The image in this scenario though is not saving against the _featured_image field.

Any thoughts on this?

#1379585

Hello,

There isn't such a built-in feature within Toolset Forms plugin, you can consider custom JS codes, for example, edit your post form, click "JS Editor" and add below JS codes:

jQuery(document).on('cred_form_ready', function() {
      
  jQuery('[name="_featured_image"]').attr('accept', 'image/jpeg,image/png,jpg|png');
    
});

More help:
hidden link

#1380621
imageforthisfieldmodal.png

Hi Luo,
You've answered a part of my question (thank you for this) but the main issue I'm trying to actually resolve is force the file input type so that the UI forces the user to upload a file without giving them the option to select one that is already loaded (see attached screenshot)

<em><u>hidden link</u></em>

Please let me know if this is possible.

The following code works perfectly but the image just doesn't save to _featured_image field

<input type="file" id="_featured_image" name="_featured_image" field="_featured_image" accept="image/jpeg,image/png,jpg|png">
#1380635

You can try this, edit your post form, in section "Settings", disable option "Use the WordPress Media Library manager for image, video, audio, or file fields", and test again.