Store .PDF file in database table
-
// Add cf7 data to database function contactform7_before_send_mail( $form_to_DB ) { // Set your db details $mydb = new wpdb('username','password','database','host'); $form_to_DB = WPCF7_Submission::get_instance(); if ( $form_to_DB ) $formData = $form_to_DB->get_posted_data(); // Set Variables $username = $formData['username']; $companyname = $formData['company-name']; $signfirst = $formData['sign-1']; $dateofpurchase = $formData['date-of-purchase']; $pdfFile = $formData['comments-on-electric-fence']; // Insert into db Table $mydb->insert( 'TableName', array( 'Username' =>$username, 'CompanyName' =>$companyname, 'SignTest' =>$signfirst, 'DateTest' =>$dateofpurchase, 'Upload' =>$pdfFile ), array( '%s' ) ); } remove_all_filters ('wpcf7_before_send_mail'); add_action( 'wpcf7_before_send_mail', 'contactform7_before_send_mail' );
Hi,
I have been having a great time inserting data into the table that I created with your plugin. I just cant seem to insert an uploaded .pdf file from the CF7 form. It does go through to the table row and inserts the username, companyname, etc. although it does send through the pdf file, when I try to read it on the publisher or viewing the data on the table itself then in that row it just gives me this output ‘cd809a1cc070a22ff6deafd4a2ac02ac’
I have tried varbinary, blob, largeblob and text.
I really cant seem to get it to work so if you could kindly give me direction in the data designer what I should do to be able to store and view the file I would REALLY appreciate it!
Kind Regards
Brandon
- The topic ‘Store .PDF file in database table’ is closed to new replies.