Uploads Only 10 files in month step by step

 
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
 
    $con = mysqli_connect("localhost","root","","demo");
 
date_default_timezone_set('Asia/Kolkata');
 
    $date=Date("Y-m-d");
 
 
    
 
    if(isset($_POST['submit']))
    {
        extract($_POST);
 
        $name1=$_FILES['photo']['name'];
  $type=$_FILES['photo']['type'];
  $size=$_FILES['photo']['size'];
  $temp=$_FILES['photo']['tmp_name'];
  if($name1){
 $upload= "posts/";
            $imgExt=strtolower(pathinfo($name1, PATHINFO_EXTENSION));
            $valid_ext= array('jpg','png','jpeg' );
            $photo= rand(1000,1000000).".".$imgExt;
            move_uploaded_file($temp,$upload.$photo);
          }
 
 
        $add=mysqli_query($con,"insert into file_upload(User_id, File_name, Date) values('1','$photo','$date')") or die(mysqli_error($con));
        if($add)
 
                 {
 
                   echo '<script type="text/javascript">';
                   echo " alert('data insert');";
                    
                   echo '</script>';
   
                      }
                     else
                     {
                     echo '<script type="text/javascript">';
                     echo " alert('data Not insert');";
                     echo '</script>';
                         
   
                     }
 
    }
 
    $view=mysqli_query($con,"select * from file_upload where User_id='1' and MONTH(`Date`) = MONTH(CURRENT_DATE()) AND YEAR(`Date`) = YEAR(CURRENT_DATE())") or die(mysqli_error($con));
 
    $fetch=mysqli_fetch_array($view);
    $a=mysqli_num_rows($view);
 
    ?>
 
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>File upload with 10 validation</title>
    </head>
    <body>
    <form method="post" enctype="multipart/form-data">
    <input type="file" name="photo" ><br>
    <?php  if($a >=10){?>
     
    <input type="submit" name="submit" value="Submit" disabled />
    <?php }else{  ?>   <input type="submit" name="submit" value="Submit"  /> <?php     } ?>
    </form>
    </body>
    </html>
 
 
<?php

    $con = mysqli_connect("localhost","root","","demo");

date_default_timezone_set('Asia/Kolkata');

    $date=Date("Y-m-d");


   

    if(isset($_POST['submit']))
    {
        extract($_POST);

        $name1=$_FILES['photo']['name'];
  $type=$_FILES['photo']['type'];
  $size=$_FILES['photo']['size'];
  $temp=$_FILES['photo']['tmp_name'];
  if($name1){
 $upload= "posts/";
            $imgExt=strtolower(pathinfo($name1, PATHINFO_EXTENSION));
            $valid_ext= array('jpg','png','jpeg' );
            $photo= rand(1000,1000000).".".$imgExt;
            move_uploaded_file($temp,$upload.$photo);
          }


        $add=mysqli_query($con,"insert into file_upload(User_id, File_name, Date) values('1','$photo','$date')") or die(mysqli_error($con));
        if($add)

                 {

                   echo '<script type="text/javascript">';
                   echo " alert('data insert');";
                   
                   echo '</script>';
  
                      }
                     else
                     {
                     echo '<script type="text/javascript">';
                     echo " alert('data Not insert');";
                     echo '</script>';
                        
  
                     }

    }

    $view=mysqli_query($con,"select * from file_upload where User_id='1' and MONTH(`Date`) = MONTH(CURRENT_DATE()) AND YEAR(`Date`) = YEAR(CURRENT_DATE())") or die(mysqli_error($con));

    $fetch=mysqli_fetch_array($view);
    $a=mysqli_num_rows($view);

    ?>

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>File upload with 10 validation</title>
    </head>
    <body>
    <form method="post" enctype="multipart/form-data">
    <input type="file" name="photo" ><br>
    <?php  if($a >=10){?> 
    
    <input type="submit" name="submit" value="Submit" disabled /> 
    <?php }else{  ?>   <input type="submit" name="submit" value="Submit"  /> <?php     } ?>
    </form>
    </body>
    </html>

Comments

  1. Your blog is so nice, and the article is very good it helps to so many people.
    PHP Training in Hyderabad

    ReplyDelete

  2. Thanks For Sharing. It IS very helpful For Everyone ....
    If You Are Looking Best PHP training in chandigarh click here

    ReplyDelete
  3. Shahni Digital Media provides complete digital marketing solutions to your business. e.g. ppc, social media marketing, web designing & development. Hire us to grow up your business high.
    Digital Marketing Company Bhopal
    Website Designing Company Bhopal
    SEO Company in Bhopal
    ORM Company India

    ReplyDelete
  4. Pretty! This was a really wonderful article. Thanks for providing these details.
    UI Development Training in Bangalore
    Reactjs Training in Bangalore

    ReplyDelete

Post a Comment

Popular posts from this blog

How to seperate character from string in php

How to Delete record using PHP Ajax