Reputation: 3
I have a script that work perfectly with input file except .txt file. I really dunno whats wrong with it. But if i open other extension (like .csv, .rar, .zip, etc) it works and i got something on my $_POST. But if i go with any *.txt file i just get array null on my $_POST.
If i use this code :
$sListText = file_get_contents("act20170713.txt");
echo "<br/>".nl2br($sListText);
Its just work perfectly. But if i use :
$fileexcel = $_FILES['txt']['tmp_name'];
echo $fileexcel;
i got an array null only with *.txt file
Can someone explain it to me or maybe have the solution for it? Any answer will be appreciated. Thank in advance.
Kind regards, Fondra
I add some screenshot for more detail enter image description here
Full code :
<form action="" method="post" enctype="multipart/form-data" name="form2" id="form2">
<div class="row">
<div class="col-md-3">
<input id="file" type="file" name="txt" style="text-align:right;-moz-opacity:0;filter:alpha(opacity:0);opacity:1;z-index: 2;"/>
</div>
<div class="col-md-3" style="padding-left:4.5%"><input type="submit" name="list" class="btn btn-info" value="Show"/></div>
<div class="col-md-3"></div>
<div class="col-md-3" ><input type="submit" name="clear" class="btn btn-default" value="Clear" style="float:right"/></div>
</div>
</form>
<?php if (isset($_POST['list'])){
var_dump($_FILES);
$fileexcel = $_FILES['txt']['tmp_name'];
echo $fileexcel;
print_r($_FILES['txt']);
//echo "test";
//$sListText = file_get_contents("act20170713.txt");
//$data = explode("\n", $sListText);
?}
Upvotes: 0
Views: 489
Reputation: 1282
Is the txt file very larger? Perhaps PHP is choking on the file size? Check upload_max_filesize
and post_max_size
php config settings - I've seen situations where the file exceeds post_max_size
did not return any errors, similar to your situation.
Upvotes: 0
Reputation: 177
I think you can var_dump($_FILEs)
to see,and check you html form is have enctype="multipart/form-data"
Upvotes: 1