Why am I getting this error?
Posted: Tue Feb 22, 2011 9:25 pm
I thought it might be a permissions thing, but I've changed the folder to 775 and still no dice. If it makes a difference, the form is currently in the root, but I've tried it in the same folder as the plugin (/wp-content/plugins/wp-members-pages/) and I get the same error. Any idea what might be wrong here?
Error message:
Warning: move_uploaded_file(/wp-content/plugins/wp-members-pages/images/testface.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/efarrell/public_html/app.php on line 15
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpTNgGma' to '/wp-content/plugins/wp-members-pages/images/testface.jpg' in /home/efarrell/public_html/app.php on line 15
There was an error uploading your headshot, please try again!There was an error uploading your logo, please try again!
PHP code:
Error message:
Warning: move_uploaded_file(/wp-content/plugins/wp-members-pages/images/testface.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/efarrell/public_html/app.php on line 15
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpTNgGma' to '/wp-content/plugins/wp-members-pages/images/testface.jpg' in /home/efarrell/public_html/app.php on line 15
There was an error uploading your headshot, please try again!There was an error uploading your logo, please try again!
PHP code:
Code: Select all
<?php
if(isset($_POST['firstname'])){
// Where the file is going to be placed
$target_path = "/wp-content/plugins/wp-members-pages/images/";
/* headshot */
$target_path = $target_path . basename( $_FILES['headshot']['name']);
$target_path = "/wp-content/plugins/wp-members-pages/images/";
$target_path = $target_path . basename( $_FILES['headshot']['name']);
if(move_uploaded_file($_FILES['headshot']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['headshot']['name']).
" has been uploaded";
print_r($_POST);
} else{
echo "There was an error uploading your headshot, please try again!";
}
/* logo */
$target_path = $target_path . basename( $_FILES['logo']['name']);
$target_path = "/wp-content/plugins/wp-members-pages/images/";
$target_path = $target_path . basename( $_FILES['logo']['name']);
if(move_uploaded_file($_FILES['']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['']['name']).
" has been uploaded";
print_r($_POST);
} else{
echo "There was an error uploading your logo, please try again!";
}
}
if (empty($_POST['firstname'])){
echo '<form enctype="multipart/form-data" action="" method="post">';
echo '<input type="text" name="firstname" /><br />';
echo '<input name="headshot" type="file" /><br />';
echo '<input name="logo" type="file" /><br />';
echo '<input type="submit" value="Upload File" />';
echo '</form>';
}
?>