Hi I am trying to upload a file that is contained within a form I have on a page template in WordPress.
I cannot seem to upload the file to my specified directory, whether there is a special way of doing this or my file path information is not correct.
Here is my code: ( this is currently insecure for simple testing purposes, so please ignore.)
$target_path = dirname(__FILE__).'/event-submissions/';
$target_path = $target_path . basename( $_FILES['event-image']['name']);
if( move_uploaded_file($_FILES['event-image']['tmp_name'], $target_path) ) {
echo "The file ". basename( $_FILES['event-image']['name']). " has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
exit;
}
$target_path displays /homepages/4/d335638566/htdocs/dev/assets/themes/momentmag/event-submissions/FILENAME.FILE_EXT
So obviously I get the message "There was an error uploading the file, please try again!"
If anyone can shed any light on this - great!
Thanks