Stephen Posted October 27, 2008 Share Posted October 27, 2008 set_time_limit(0); $_vew["config"]["letters"] = intval(htmlentities($_POST["letters"], ENT_QUOTES)); function vew_strlen_allow($str) { if (strlen($str) <= $_vew["config"]["letters"]) { return true; } else { return false; } } $_vew["file"]["data"] = file_get_contents($_FILES["file"]["tmp_name"]); echo($_vew["file"]["data"]); $_vew["file"]["array"] = explode("\n", $_vew["file"]["data"]); print_r($_vew["file"]["array"]); $_vew["file"]["array_filter"] = array_filter($_vew["file"]["array"], "vew_strlen_allow"); print_r($_vew["file"]["array_filter"]); echo(implode("\n", $_vew["file"]["array_filter"])); Everything echos/prints correctly up to print_r($_vew["file"]["array_filter"]); echo(implode("\n", $_vew["file"]["array_filter"])); It just returns blank. I don't know what's wrong with it. EDIT: By the way, it returned this: 1 22 333 4444 55555 666 6 777777Array ( [0] => 1 [1] => 22 [2] => 333 [3] => 4444 [4] => 55555 [5] => 666 [6] => 6 [7] => 777777 ) Array ( ) Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 27, 2008 Share Posted October 27, 2008 Not enough information for a meaningful answer. Please show us the form that this is processing. Ken Quote Link to comment Share on other sites More sharing options...
Stephen Posted October 27, 2008 Author Share Posted October 27, 2008 <?php if (empty($_POST["submit"])) { echo(" <form enctype=\"multipart/form-data\" action=\"\" method=\"POST\"> File: <input name=\"file\" type=\"file\" /><br /> Letters: <input name=\"letters\" type=\"text\" value=\"3\" /><br /> <input type=\"submit\" value=\"Upload\" name=\"submit\" /> </form> "); } else { set_time_limit(0); function vew_strlen_allow($str) { if (strlen($str) <= (intval(htmlentities($_POST["letters"], ENT_QUOTES))+1)) { return true; } else { return false; } } $_vew["file"]["data"] = file_get_contents($_FILES["file"]["tmp_name"]); $_vew["file"]["array"] = explode("\n", $_vew["file"]["data"]); $_vew["file"]["array_filter"] = array_filter($_vew["file"]["array"], "vew_strlen_allow"); header("Content-disposition: attachment; filename=" . $_FILES["file"]["name"]); header("Content-type: application/octet-stream"); echo(implode("\n", $_vew["file"]["array_filter"])); exit; } ?> New full code, and it's fixed. I got rid of that letters variable and put it directly into the function. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.