Exemplo n.º 1
0
Arquivo: main.php Projeto: sjhhh3/log
    session_destroy();
    header('Location: index.php');
    exit;
}
$name = $_FILES['file']['name'];
$extension = strtolower(substr($name, strpos($name, '.') + 1));
$size = $_FILES['file']['size'];
$max_size = 2097152;
$type = $_FILES['file']['type'];
$tmp_name = $_FILES['file']['tmp_name'];
if (isset($name)) {
    if (!empty($name)) {
        if (($extension == 'jpg' || $extension == 'jpeg') && $type == 'image/jpeg' && $sinze <= $max_size) {
            $location = 'upload/';
            $md5_name = substr(md5(time()), 0, 10);
            change_profile_image($session_user_id, $tmp_name, $extension, $md5_name);
            if (move_uploaded_file($tmp_name, $location . $md5_name . '.' . $extension)) {
                echo 'File Have Been Uploaded.';
                header('Location: pic.php');
            } else {
                echo 'There was an error.';
            }
        } else {
            echo 'File must be Jpg/Jpeg within 2mb or less.';
        }
    } else {
        echo 'Please choose a file.';
    }
}
?>
            <h1>Logged In. Please Upload Your File.</h1><br><br>
Exemplo n.º 2
0
            echo output_errors($errors);
        }
    }
    if (isset($_FILES['profile']) === true) {
        if (empty($_FILES['profile']['name']) === true) {
            echo 'Upload a Profile Picture<br>';
        } else {
            $allowed = array('jpg', 'jpg', 'gif', 'png');
            $file_name = $_FILES['profile']['name'];
            //file name
            $file_extn = strtolower(end(explode('.', $file_name)));
            //the last word after the last period = the extension
            $file_temp = $_FILES['profile']['tmp_name'];
            //need to add a file size limit
            if (in_array($file_extn, $allowed) === true) {
                change_profile_image($session_user_id, $file_temp, $file_extn);
                echo '<meta HTTP-EQUIV="REFRESH" content="0; url=' . $current_file . '">';
            } else {
                echo 'Incorrect file type. Please choose: ';
                echo implode(', ', $allowed);
            }
        }
    }
    if (empty($user_data['profile']) === false) {
        echo '<img src="', $user_data['profile'], '" alt="', $user_data['first_name'], '\'s Profile Image">';
    }
    ?>
	<form action="" method="post" enctype="multipart/form-data">
	<input type="file" name="profile"> <input type="submit">
	</form>
	<br>
Exemplo n.º 3
0
	<h2> Hello,<?php 
        echo $user_data['first_name'];
        ?>
!! </h2>
	<?php 
        if (isset($_FILES['profile']) === true) {
            if (empty($_FILES['profile']['name']) === true) {
                echo 'Please Choose a File';
            } else {
                $allowed = array('jpg', 'jpeg', 'gif', 'png');
                $file_name = $_FILES['profile']['name'];
                $file_extn = strtolower(end(explode('.', $file_name)));
                $file_temp = $file_name = $_FILES['profile']['tmp_name'];
                if (in_array($file_extn, $allowed) === true) {
                    $current = $user_data['username'];
                    change_profile_image($s_id, $file_temp, $file_extn);
                    header('Location: ' . $current);
                    exit;
                } else {
                    echo 'Incorrect file format .Allowed Format are :';
                    echo implode(', ', $allowed);
                }
            }
        }
        if (empty($user_data['profile']) === false) {
            echo '<img src ="', $user_data['profile'], '" alt="', $user_data['first_name'], '\'s Profile Image">';
        }
        ?>
	<form action =	"" method="POST" enctype="multipart/form-data">
		<input type="file" name="profile"> <br>
		<input type="submit" class ="hvr-back-pulse" style="width:80px; height:40px;"><br>