charlie
charlie

Reputation: 115

PHP multiple file upload not getting any further when submitting form

I have this PHP code:

if(isset($_POST["submit"])) {
    echo 'submit';
    foreach($_FILES['file_name']['name'] as $key => $value) {
        echo 'file';
        $handle = fopen($_FILES['file_name']['tmp_name'][$key], "r");
        fgetcsv($handle);

        //then loop through each row
        while(($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
            echo 'DATA: '.$data[0].'<br>';
            //and insert the data
            /*$stmt = $pdo_conn->prepare("INSERT into customer2 (industry, company, address1, town, postcode, county, phone, forename, contact_position) values (:industry, :company, :address1, :town, :postcode, :county, :phone, :forename, :contact_position) ");
            $stmt->execute(array(':industry' => $data[0], 
            ':company' => $data[1], 
            ':address1' => $data[2], 
            ':town' => $data[3], 
            ':postcode' => $data[4], 
            ':county' => $data[5], 
            ':phone' => $data[8], 
            ':forename' => $data[13], 
            ':contact_position' => $data[14] ));*/

            /*$sql="INSERT into customer2 (industry, company, address1, town, postcode, county, phone, forename, contact_position) values ('".$data[0]."', '".$data[1]."', '".$data[2]."', '".$data[3]."', '".$data[4]."', '".$data[5]."', '".$data[8]."', '".$data[13]."', '".$data[14]."'); ";
            $rs=mysql_query($sql,$conn) or die(mysql_error());*/
        }
    }
}

that runs on form submit, my form looks like:

<form method="post" action="upload_records" enctype="multipart/form-data">
<table width="600" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2"><input type="file" name="file_name" multiple="multiple" /></td>
  </tr>
  <tr>
    <td colspan="2" align="right"><input type="submit" name="submit" value="Upload" /></td>
  </tr>
</table>
</form>

when i submit the form, i see the word submit but even though a file has been chosen, nothing else is being displayed below this

i can see the file being uploaded when using chrome (showing the percentage in the bottom status bar)

Upvotes: 0

Views: 38

Answers (1)

Dave Goten
Dave Goten

Reputation: 701

Have you checked your server's filesize limits? You can try increasing them with:

ini_set('memory_limit', '96M');
ini_set('post_max_size', '64M');
ini_set('upload_max_filesize', '64M');

Eh, I wanted to post it as a comment but need more points soo, that's my lame attempt at making my question as an answer.

Upvotes: 4

Related Questions