Invalid file type when using wp_upload_bits to upload PDF to a custom post type

Ahh I figured it out. After echoing and print_r every single thing I could I figured out that this line: $uploaded_file = wp_upload_bits($_FILES[$pdf_field[‘name’]], null, file_get_contents($_FILES[$pdf_field[‘tmp_name’]])); Needed to be changed to this: $uploaded_file = wp_upload_bits($pdf[‘name’], null, file_get_contents($pdf[‘tmp_name’])); The original problem I had in the first place was not being able to pass my $_FILE array directly … Read more

Upload images – Theme options

I can’t comment on your code, but you might find this link useful: Options Framework Theme: http://wptheming.com/options-framework-theme/ This is something you have to edit carefully, but it has pretty much every type of control you can think of in there. It also had the only working MCE Editor that I could find. I wanted that … Read more

Image upload and path to custom field

Found the solution. Forgot 2 lines of code. New is line 2 and line 11. I post the complete code: if( ‘POST’ == $_SERVER[‘REQUEST_METHOD’] && !empty( $_POST[‘action’] ) && $_POST[‘action’] == “new_post”) { $file=$_FILES; // Funktion zum Image-Upload, falls sie noch nicht existiert if ( ! function_exists( ‘wp_handle_upload’ )) { require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’); … Read more

Upload an image at frontend > Create direction and/or rename filename possible?

What the similar posts (wich your found) are suggesting, is adding a filter in your functions.php wich will handle the filenames for you. All uploaded files will be filtered by this function before the upload will be handled by wp_handle_upload. Add the following lines of code in your functions.php: function wpse_82741_rename_uploaded_file( $image ) { global … Read more

Upload a custom csv file, read contents and delete that file

Enable upload of CSV files, which are not in the default allowed files (see here) Hook into add_attachment action hook to detect when the desired file is uploaded Do whatever you need to do using that hook, then trigger wp_delete_attachment once the file has been processed. Depending on what you want to do, it may … Read more

How to upload prc file type?

This article explains a method in which you can add a file type to the list of allowed file types. Copy and paste the following code into your functions.php: add_filter(‘upload_mimes’, ‘custom_upload_mimes’); function custom_upload_mimes ( $existing_mimes=array() ) { // add your extension to the array $existing_mimes[‘prc’] = ‘application/x-mobipocket-ebook’; // add as many as you like // … Read more