Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

closed as too localized by toscho Jul 18 '12 at 21:37

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

1 Answer

I know this might sound kind of elementary but it could be folder permissions thing. Double check to make sure that the folder is writable. If not you will have to change the permissions by chmod via your ftp client.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.