<?php
$target = "subdom/dema/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
//This is our size condition
if ($uploaded_size > 350000)
{
echo "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 "added!";
}
//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "Demo ". basename( $_FILES['uploadedfile']['name']). " added";
}
else
{
echo "error.";
}
}
?>
if (isset($_FILES)){
//Define target file location
$target = "subdom/dema/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
//Break apart the file and fill in things to check
$allowedExts = array("dem");
$temp = explode(".", $_FILES['uploaded']['name']);
$extension = end($temp);
$tmp_filename = str_replace("/tmp/php", "", $_FILES['uploaded']['tmp_name']);
//Check if the file matches extension and MIME
if ($_FILES['uploaded']['type'] == "application/octet-stream"
&& in_array($extension, $allowedExts)) {
$ok = true;
} else {
echo "Wrong file type.<br />";
$ok = false;
}
//Make sure the file isn't too big
if ($_FILES['uploaded']['size'] > 350000){
$ok = true;
} else {
echo "File too large.<br />";
$ok = false;
}
//Move the file somewhere useful
if($ok){
move_uploaded_file($_FILES['uploaded']['tmp_name'],$target);
} else {
echo "Check the files for the errors above.<br />";
}
}
Category Forum
Modifications and Requests - 8Labels
None yet
Statistics
2 participants
Notifications
You are not receiving notifications from this thread.
Related Questions