Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • uploading file

    • 0
    • 0
    • 0
    • 2
    • 0
    • 0
    • 0
    • 393
    Answer it

    when i execute this file.php only it will upload, when i run in Mainlayout.php its not uploading. Below file is File.php, its to upload csv file.. Canone help me plzzzzzzzz

     

    <form name="import" method="post" enctype="multipart/form-data">
                <input type="file" name="file" />
                <input type="submit" name="submit" value="Submit" />
            </form>
            <?php
            include ("connection1.php");
    
            if (isset(_POST["submit"])) {
                $file = _FILES['file']['tmp_name'];
                $handle = fopen($file, "r");
                $c = 0;
                while (($filesop = fgetcsv($handle, 1000, ",")) !== false) {
                    $contact = $filesop[0];
    
    
                    if (preg_match('/(7|8|9)\d{9}/', $contact)) { // phone number is valid
    
                        $sql = mysql_query("INSERT INTO csv1 (contact) VALUES ('$contact')");
                        $c = $c + 1;
                    } 
                }
    
                if ($sql) {
                    echo "Your Database Has Imported Successfully. You have Inserted " . $c . " Records";
                } else {
                    echo "Sorry! There is a Some Problem.";
                }
            }
            ?>
    
        </div>
        </body>

     

 2 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: