I've done far more complex things than this, but for some reason, I seem to have the logic of a drunk toddler on this one
Any help is greatly appreciated.
Moderator: General Moderators
Code: Select all
<?php
if (isset($_POST["logo"])){
$target = "/wp-content/plugins/wp-members-pages/images/";
$target = $target . basename( $_FILES['logo']['name']) ;
$ok=1;
//This is our size condition
if ($uploaded_size > 350000)
{
echo "Your file is too large.<br>";
$ok=0;
}
//This is our limit file type condition
if ($uploaded_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}
//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}
//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['logo']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
}
if (empty($_POST["logo"])){
echo '<form action="" method="post" >';
echo '<input name="logo" type="file" />';
echo '<input type="submit" value="Upload" />';
echo '</form>';
}
?>Code: Select all
enctype="multipart/form-data"Code: Select all
<?php
if (isset($_POST["uploadedfile"])){
// Where the file is going to be placed
$target_path = "/test/";
/* Add the original filename to our target path.
Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$target_path = "/test/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
}
if (empty($_POST["uploadedfile"])){
echo '<form enctype="multipart/form-data" action="" method="POST">';
echo '<input type="hidden" name="MAX_FILE_SIZE" value="100000" />';
echo '<input name="uploadedfile" type="file" />';
echo '<input type="submit" value="Upload File" />';
echo '</form>';
}
?>