This function, seems pretty standard, I am not really getting an active button that uploads to the list in my database?
if(isset($_POST['submit'])){ //THis is how you upload a picture to a website
$file = $_FILES['file'];
print_r($file);
$fileName = $_FILES['file']['name'];
$fileTmpName = $_FILES['file']['tmp_name'];
$fileSize = $_FILES['file']['size'];
$fileError = $_FILES['file']['error'];
$fileType = $_FILES['file']['type'];
$fileExt = explode('.', $fileName);
$fileActualExt = strtolower(end($fileExt));
//array for
$allowed = array('jpg', 'jpeg', 'png', 'pdf');
if(in_array($fileActualExt, $allowed)){
if($fileError === 0) {
if($fileSize < 1000000) {
$fileNameNew = uniqid ('',true). ".". $fileActualExt;
$fileDestination = '_uploads/'. $fileNameNew;
move_uploaded_file($fileTmpName);
header("Location: index.php");
echo "success";
}else{echo "Your file is too big hoe";}
}
else{echo "good try, youll have to upload again";}
}
else{echo "You cannot upload file of this type";}
}
echo $_POST['value'];
//if $_POST == "yes"
$encodedStr = base64_encode('yes.txt'); //may need to encode inside of a seperate function
//may need to implement a search based on user input
//if search matches the stored access value, then decode the .txt document
echo $encodedStr; //cannot concat a string by itself, must make into a numeric value
$decodedStr = base64_decode ($encodedStr);
echo nl2br($decodedStr);
?>
Is anything unusual about the above code? new to php.
2
Answers
Try this one for uploding a image .
Try this one for uploding a image .