Saturday, January 2, 2016

fb

<?php
// File uploading with general php
if(isset($_FILES['file'])) {
$file = $_FILES['file'];
//File properties
$file_name = $file['name'];
$file_tmp = $file['tmp_name'];
$file_size = $file['size'];
$file_error = $file['error'];
//Work out the file extension
$file_ext = explode('.', $file_name);
$file_ext = strtolower(end($file_ext));
$allowed = array('jpg', 'gif');
if(in_array($file_ext, $allowed)) {
if($file_error===0) {
if($file_size<=201552000) {
$file_destination = 'uploads/' . $file_name;
if(move_uploaded_file($file_tmp, $file_destination)) {
echo $file_destination;
}
}
}
}
}
?>
<h3>File upload</h3>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" name="submit" value="UPLOAD">
</form>

__________________________________________________________________
<?php
// File uploading with general php
if(isset($_FILES['file'])) {
$file = $_FILES['file'];
//File properties
$file_name = $file['name'];
$file_tmp = $file['tmp_name'];
$file_size = $file['size'];
$file_error = $file['error'];
//Work out the file extension
$file_ext = explode('.', $file_name);
$file_ext = strtolower(end($file_ext));
$allowed = array('jpg', 'gif');
if(in_array($file_ext, $allowed)) {
if($file_error===0) {
if($file_size<=201552000) {
$file_destination = 'uploads/' . $file_name;
if(move_uploaded_file($file_tmp, $file_destination)) {
echo $file_destination;
}
}
}
}
}
?>
<h3>File upload</h3>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" name="submit" value="UPLOAD">
</form>
__________________-------
</head>
<body>
<?php
if(isset($_POST['user_email']) ==true && empty($_POST['user_email'])==false){
$email = $_POST['user_email'];
if(filter_var($email, FILTER_VALIDATE_EMAIL)==true){
echo "<h2 class='valid'>Your email address $email is a valid address</h2>";
} else {
echo "<h2 class='invalid'>You have put an invalid address</h2>";
}

}
?>
<form method="post" action="">
<p><input type="text" name="user_email" placeholder="Put email address"></p>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>

No comments:

Post a Comment