How to check if uploaded file is .pdf not .jpeg?

I like to use the following: First I initiate an array of supported mime types: $supportedTypes = array( ‘application/pdf’ ); Next I get my actual uploaded file type: $fileType = $_FILES[‘type’][0] Then I use wp_check_filetype() to get the extension and mimetype: $fileArray = wp_check_filetype( basename( $_FILES[‘name’][0] ) ); Finally I run a conditional to make … Read more

Correct Syntax for uploading files to custom directory in WordPress

(Update to answer: 05.27.15) What finally worked is using ABSPATH: $folderPath = “/jobtracking/files/standard/{$projID}”; mkdir(ABSPATH.$folderPath, 0755, true); $filename = basename($_FILES[‘Attach_Files’][‘name’]); $filetype = $_FILES[‘Attach_Files’][‘type’]; $datei = “files/standard/{$projID}/{$filename}”; $target_path = ABSPATH.$folderPath . “https://wordpress.stackexchange.com/” . $filename; if(move_uploaded_file($_FILES[‘Attach_Files’][‘tmp_name’], $target_path)) { mysql_query(“INSERT INTO files (files.name, files.project, files.user, files.added, files.datei, files.type, files.folder, files.visible) VALUES(‘{$filename}’, ‘{$projID}’, 5, UNIX_TIMESTAMP(now()), ‘{$datei}’, ‘{$filetype}’, 0, ‘ ‘)”); … Read more

jQuery form plugin, submit in the wordpress way

If you want to use the WordPress functions in your process.php file then there is a way for you. simply put these two lines of code at the top of your process.php file $blogheader = explode(“wp-content”,$_SERVER[“SCRIPT_FILENAME”]); include $blogheader[0].”wp-blog-header.php”; Now you can use the WordPress functions in your file and do what you want. Will that … Read more

Unable to create directory

First issue is related with ownership of the directory. Second issue is, you will have to make directory within directory so consider using following UNIX command: sudo mkdir -p wp-content/uploads/2014/08 here p flag lets you create directory within directory Third issue is related with the file permissions ( theme-editor.php) use : ls -lah to view … Read more

Saving an upload media meta box field

use these: $imgurl = isset( $values[‘upload_image’] ) ? esc_attr( $values[‘upload_image’][0] ) : ”; <input id=”upload_image” type=”text” size=”36″ name=”upload_image” value=”<?php echo $imgurl; ?>” /> <input id=”upload_image_button” type=”button” value=”Upload Image” /> if( isset( $_POST[‘upload_image’] ) ) update_post_meta( $post_id, ‘upload_image’, wp_kses_data( $_POST[‘upload_image’] ) );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)