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

    • 0
    • 0
    • 0
    • 2
    • 0
    • 0
    • 0
    • 460
    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

     

    1. <form name="import" method="post" enctype="multipart/form-data">
    2. <input type="file" name="file" />
    3. <input type="submit" name="submit" value="Submit" />
    4. </form>
    5. <?php
    6. include ("connection1.php");
    7.  
    8. if (isset(_POST["submit"])) {
    9. $file = _FILES['file']['tmp_name'];
    10. $handle = fopen($file, "r");
    11. $c = 0;
    12. while (($filesop = fgetcsv($handle, 1000, ",")) !== false) {
    13. $contact = $filesop[0];
    14.  
    15.  
    16. if (preg_match('/(7|8|9)\d{9}/', $contact)) { // phone number is valid
    17.  
    18. $sql = mysql_query("INSERT INTO csv1 (contact) VALUES ('$contact')");
    19. $c = $c + 1;
    20. }
    21. }
    22.  
    23. if ($sql) {
    24. echo "Your Database Has Imported Successfully. You have Inserted " . $c . " Records";
    25. } else {
    26. echo "Sorry! There is a Some Problem.";
    27. }
    28. }
    29. ?>
    30.  
    31. </div>
    32. </body>

     

 2 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: