Skip to content

Commit 55420de

Browse files
committed
add enctype='multipart/form-data' if form has a file input
1 parent e6e5651 commit 55420de

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

classes/class-cpt-wplf-form.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,16 @@ function wplf_form( $id , $content = '', $xclass = '' ) {
422422
// you can override the content via a parameter
423423
$content = get_post( $id )->post_content;
424424
}
425+
426+
$multipart = "";
427+
// check if form contains file inputs
428+
if(strpos($content, "type='file'") > -1 || strpos($content, "type=\"file\"") > -1){
429+
$multipart = "enctype='multipart/form-data'";
430+
}
431+
425432
ob_start();
426433
?>
427-
<form class="libre-form libre-form-<?php echo $id . ' ' . $xclass; ?>">
434+
<form class="libre-form libre-form-<?php echo $id . ' ' . $xclass; ?>" <?php echo $multipart; ?>>
428435
<?php echo apply_filters( 'wplf_form', $content ); ?>
429436
<input type="hidden" name="referrer" value="<?php the_permalink(); ?>">
430437
<input type="hidden" name="_form_id" value="<?php esc_attr_e( $id ); ?>">

0 commit comments

Comments
 (0)