Program to create thumbnail
-
Hello. Prompt how to create a preview of the PDF file is downloaded to their handler.
sample code<form method="post" action="<?php bloginfo('template_url'); ?>/handler.php" enctype="multipart/form-data" class="form-horizontal"> <?php wp_nonce_field( 'pdf_files', 'fileup_nonce' ); ?> <input name="pdf_files" id="uploades" required type="file" class="custom_media_url"/> <input name="xsq" class="get-val" value=""/> <button id="send" name="send" class="btn btn-primary">Отправить</button> </form>
and handler.php
if(isset($_POST['send']) == '1') { $new_post = array( 'ID' => '', 'post_author' => $user->ID, 'post_category' => 'portfolio-party', 'post_title' => $post_title, 'post_status' => 'publish' ); $post_id = wp_insert_post($new_post); if ( ! function_exists( 'wp_handle_upload' ) ) { require_once( ABSPATH . 'wp-admin/includes/file.php' ); } $uploadedfile = $_FILES['pdf_files']; $upload_overrides = array( 'test_form' => false ); $movefile = wp_handle_upload( $uploadedfile, $upload_overrides ); if ( $movefile && !isset( $movefile['error'] ) ) { $filename = $movefile['file']; $parent_post_id = $applicant_id; $wp_upload_dir = wp_upload_dir(); $attachment = array( 'guid' => $wp_upload_dir['url'] . '/' . basename( $filename ), 'post_mime_type' => $filetype['type'], 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ), 'post_status' => 'inherit' ); // Insert the attachment. $attach_id = wp_insert_attachment( $attachment, $filename, $parent_post_id ); //$attach_data = wp_generate_attachment_metadata( $attach_id, $filename ); wp_update_attachment_metadata( $attach_id, $attach_data ); // Update File Field update_field('pdf_files', $attach_id, $post_id); } else { }
I tried to add the code in this topic, but not work.
https://www.ads-software.com/support/topic/acf-front-end-editor/I suspect that your plug-in only if the file is saved in admin’s part.
If anything, I’m sorry for my english.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Program to create thumbnail’ is closed to new replies.