Add file upload with validation to custom form

<?php /* Template Name: Contact-Page-with-upload * * A Custom PHP Contact us page. Add or change form fields on line 28 and in the form itself. * Jquery is used to add/remove Bootstrap has-error class to invalid fields. */ /** * Get Error Class * * @return string; */ $response=””; function getErrorClass($failedKeys, $key) { if(isset($failedKeys) … Read more

Moving wp-content folder to public_html

I was able to fix this problem by using this code instead of the one above: define(‘WP_CONTENT_DIR’, $_SERVER[‘DOCUMENT_ROOT’] . ‘/wp-content’); define(‘WP_CONTENT_URL’, ‘http://’ . $_SERVER[‘HTTP_HOST’] . ‘/wp-content’);

Hide obj path in source code

You could use admin-ajax.php to create a simple file proxy: add_action(‘wp_ajax_proxy_for_object1’, ‘proxy_for_object1’); add_action(‘wp_ajax_no_priv_proxy_for_object1’, ‘proxy_for_object1’); function proxy_for_object1() { $mimetype=””; // set to matching file MIME type header(“Content-type: “.$mimetype.”;”); echo file_get_contents(‘/wp-content/uploads/xx/thenameofmyfile.ext’); exit; } Then set the object resource URL to admin-ajax.php?action=proxy_for_object1 It will of course be fully accessible through the provided URL anyway, so this is really … Read more

File Upload Management

You can start yout work with upload_dir filtering. However, I wouldn’t recommend it (change this functionality). You will need to track few types of uploads and then track whoever is the parent of the upload. It’s more complicated, then joyful task.