I have a custom PHP submission form wherein if I submit the form the entry will be created as a custom post. I am able to update post meta boxes for textareas and input fields but can't get uploaded image to save as an image attached in a post's back end. some of the code that I am using but is not working:

$target_dir = "/wp-content/uploads/user-uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.