Error in while uploading file in main page

hii Good Evening FRIENDS…

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

    <script language=JavaScript>
        function check_length(my_form)
            maxLen = 160; // max number of characters allowed
            if (my_form.my_text.value.length >= maxLen)
                // Alert message if maximum limit is reached. 
                // If required Alert can be removed. 
                var msg = "You have reached your maximum limit of characters allowed";
                // Reached the Maximum length so trim the textarea
                my_form.my_text.value = my_form.my_text.value.substring(0, maxLen);
            { // Maximum length not reached so update the value of my_text counter
                my_form.text_num.value = maxLen - my_form.my_text.value.length;

    <style type="text/css">
        .style1 {font-family: "Times New Roman", Times, serif}

    <div style="margin-left:50px; margin-top: -1em;font-family: initial;">
        <h3>Professional Sms</h3></div>
    <form action="" method="post">
        <table border="3" style="margin-left:500px;margin-top:5px;font-family: initial;">
                    YOUR MOBILE NO:<input name="fromno" type="text" size="10" maxlength="10"></td></tr>
            <tr><td>TYPE MESSAGE:<textarea onKeyPress=check_length(this.form); onKeyDown=check_length(this.form); name=my_text rows=4 cols=30></textarea></td></tr>
            <tr><td><input size=1 value=160 name=text_num> Characters Left</td></tr>
            <tr><td><input type="submit" value="SendSMS"></td></tr>
    <div style="margin-left:553px; margin-top:-2em;">



Did you post the correct code? I don’t see anything there to upload a CSV file, just a form to enter some text.


OK, must be me then. Other than an include, I can’t see any PHP code in there, let alone anything to deal with file uploading.

sorrry i posted wrong code…

See This code for csv upload, our sir told ctrl is not coming to submit btn…

        <form name="import" method="post" enctype="multipart/form-data">
            <input type="file" name="file" /><br />
            <input type="submit" name="submit" value="Submit" />
        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.";


I don’t see an “action” parameter in your form specification, could that be causing an issue? I’ve always specified a destination or a blank to return to the same page, stuff I’m reading (which is old) suggests that leaving it out can have varying results.

One other thing, it is recommended you use


to check if your form has been submitted.

Be aware that the old mysql_* extension which you’re using is removed from version 7 of PHP (the current version). You need migrate over to using either the mysqli_* extension or PDO before your host migrates your server onto version 7 of PHP.

1 Like

What host in their right mind would just up and migrate pre existing servers from 5.x straight to 7. That seems highly unlikely.

Presumably they will offer 7 as an option for a while so as to let people choose when they want to upgrade before eventually forcing the upgrade when unpatched security holes in 5.x make it too great a risk to allow it - keeping in mind that 5.5 reaches end of life in July this year and 5.6 only has 12 months of security patch support after that so that 5.x will be officially dead in less than 18 months time.

I would say the samething, but that’s only if the host is active enough to upgrade every client to a higher and secure version. I’ve seen a couple hosts that still offer PHP 5.2 even after it’s been dead.

There are also a lot still offering 5.4 - also dead.

I guess it depends on how long it takes for someone to find a security hole in one of the dead versions and start trashing servers that are still running dead versions.

There were quite a few hosts still offering 4 for a long time after it was dead but eventually they all had to get everyone on shared hosting to upgrade. The same will probably happen in two or three years time with 5.x…

I hope so. I just recently installed CentOS and it was a pain in the butt to install everything needed for the LAMP environment and with PHPMyAdmin as a GUI for database management. CentOS 7 kept throwing me errors when I was trying to install the epel 7 version and it kept saying that the package was not found. So I had no choice but to install epel 6 and then I had to manually install every single thing which was a pain. When I installed 1 repo, that repo kept complaining about not having another repo. And when I went to install that repo, it said I had to install another repo and it just kept going on and on for hours. After like 4 or 5 hours of attempting, I finally got LAMP & PHPMyAdmin to work. I needed PHPMyAdmin because I was trying to import some data from my .sql file which I’m not sure if I can do that manually with the terminal.

In the end, I found out that I installed PHP Version 5.4 along with PHPMyAdmin Version 4.4.6. So yeah, I do get why most hosts don’t upgrade. It’s a real pain in the butt just to upgrade versions if the host is hosting on a CentOS. On the other hand, if they are running Ubuntu, it would not be a problem.

I lied. I actually got to update from PHP 5.4 to PHP 7. I guess it isn’t hard.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.