how to process and save Upload form in question form

4.19K viewsCore
0

Hello Rahul, I’m really frustating about saving and processing uploaded file in Question Form. I need you help, please.

Please give me a tutorial about it.

0

Hello Bayu,

I have updated our FAQ, with a working example. Check here: How to add a PDF upload field in AnsPress question form?.

commented on answer

Unfortunately it’s still not working in my Site. I’m using anspress 4.1.4

Forgot to mention that you’ll need to have latest codes from GitHub master branch.

I’ve updated to the latest anspress in Github but the upload form doesn’t display.

here’s the SS: https://snag.gy/hE7Lb2.jpg

Then something wrong in your site. Upload field should be visible after adding this code. I have fully tested all codes in FAQ.

It appears when I delete this code:
‘fields’ => array(
‘pdf’ => array( // This is a unique key for field.

like this:

function my_custom_question_field( $form ) {

$form[‘fields’][‘upload’] = array(
‘label’ => __( ‘PDF File’ ),
‘desc’ => __( ‘Allow single PDF file upload.’ ),
‘type’ => ‘upload’,
‘upload_args’ => array(
//’uploaded’ => true,
//’uploaded_files’ => true,
‘multiple’ => true, // Only allow single image upload.
‘max_files’ => 5,
// ‘allowed_mimes’ => ap_allowed_mimes(),
//’allowed_mimes’ => array(
// ‘pdf’ => ‘application/pdf’, // This will allow uploading of PDF file.
//),
),
);
return $form;
}
add_filter( ‘ap_question_form_fields’, ‘my_custom_question_field’ );