Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // this in home pge script
- <!doctype>
- <html>
- <head>
- <title>upload test</title>
- <script src="button.js"></script>
- </head>
- <body>
- <form action="" method="post" enctype="multipart/form-data">
- Select image to upload:
- <input id="leftbutton" type="submit" name="upload" value="Upload Foto"/>
- <input type="file" id="upload_foto" name="image"style="//display: none;" />
- </form>
- </body>
- </html>
- <?php
- $con=mysqli_connect("localhost","root","","test");
- if (mysqli_connect_errno())
- {
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }
- else{
- session_start();
- if(!isset($_SESSION["sess_email"])){
- header("Location: log.php");
- } else {
- $useremail=$_SESSION['sess_email'];
- $data=mysqli_query($con,"SELECT * FROM login WHERE email='$useremail'") ;
- while($row=mysqli_fetch_assoc($data))
- {
- echo "WECOME ".$dbfirstname=$row['firstname']."<br/>";
- echo $dblastname=$row['lastname']."<br/>";
- echo $dbuseremail=$row['email']."<br/>";
- echo "<br/>";echo "<br/>";echo "<br/>";echo "<br/>";echo "<br/>";
- }
- }
- }
- echo "<br/>";echo "<br/>";echo "<br/>";echo "<br/>";echo "<br/>";
- $cur = "USERS/";
- $gofile=$cur .$_SESSION["sess_email"];
- // 1.) for print the path
- echo $gofile;
- echo "<br/>";
- //2.) for print the path
- $des= dirname($gofile.'/'.$_SESSION["sess_email"]);echo "<br/>";
- echo $des."<br/>";
- if(isset($_FILES['image'])){
- $errors= array();
- $file_name = $_FILES['image']['name'];
- $file_size =$_FILES['image']['size'];
- $file_tmp =$_FILES['image']['tmp_name'];
- $file_type=$_FILES['image']['type'];
- $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
- $extensions = array("jpeg","jpg","png");
- if(in_array($file_ext,$extensions )=== false){
- die("extension not allowed, please choose a JPEG or PNG file.");
- }
- if($file_size > 1000000){
- $errors[]='Big File !';
- }
- if(empty($errors)==true){
- move_uploaded_file($file_tmp,$des.$file_name);
- echo "file uploaded";
- }else{
- print_r($errors);
- }
- }
- // header("Location: home12.php");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement