tcloud Posted January 18, 2011 Share Posted January 18, 2011 The script in question works perfectly on my WAMP installation. It is designed to help a computer-challenged historian publish to the web using text CSV files without her having to use FTP or edit html files. The largest data set is about 400KB. The script is using TEXTAREA form input and uploading via POST. Smaller files upload okay. The larger ones fail with a blank screen (empty html) and usually only a few hundred bytes missing. Example: 380KB data POST fails with 367KB stored on remote host. No error message is saved to the remote host directory. I suspected suhosin.post.max_value_length as it is set to 64K, but more than four times that amount is being stored on the remote host. Can suhosin.post.max_value_length still be the problem? The remote host is running: PHP 5.2.5 Apache 2.2.11 Linux O/S PHPINFO(): max_execution_time - 30 max_input_time - 60 memory_limit - 64M post_max_size - 16M upload_max_filesize - 16M suhosin.post.max_value_length - 65384 Any suggestions much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/224860-large-post-failure/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 18, 2011 Share Posted January 18, 2011 Are you actually uploading the file <input type='file'> or copy/pasting the contents of the file into the textarea and submitting the textarea contents? Quote Link to comment https://forums.phpfreaks.com/topic/224860-large-post-failure/#findComment-1161443 Share on other sites More sharing options...
Rifts Posted January 18, 2011 Share Posted January 18, 2011 also in your upload script is there a limit to the file size? Quote Link to comment https://forums.phpfreaks.com/topic/224860-large-post-failure/#findComment-1161444 Share on other sites More sharing options...
tcloud Posted January 18, 2011 Author Share Posted January 18, 2011 I have allowed her two ways to populate the TEXTAREA form -- pasting the text into it and clicking on the filename (which is on the remote host, not on her computer). There is no limit on the saved file size. <?php // requires PHP 5 or greater $debug = false ; include('functions/functions.php') ; // // default variables include('../templates/default_variables.txt') ; // $title = 'Upload CSV data' ; $revdate = date("l, F j, Y") ; // $maintenance = true ; include("../$header") ; // maintenance index ?> <tr> <td align="center"><hr /> <table width="90%"> <tr> <td> </td> <th><a href="upload.php">Upload CSV</a></th> <td> </td> <th><a href="process.php">Process CSV</a></th> <td> </td> <th><a href="makeindex.php">Create Index</a></th> <td> </td> </tr> </table> <hr /></td> </tr> </table> <div align="center"> <h2>Select a file to edit in the form below:</h2> <hr /> <table border="0"> <?php // get file information $files = glob("data/*.*") ; $nfiles = count($files) ; $ncount = 0 ; $ncols = 5 ; // $nrows = ceil($nfiles / $ncols) ; for ($nr = 0; $nr < $nrows; $nr++) { echo "<tr>\n" ; for ($nc = 0; $nc < $ncols; $nc++) { //if ( ($nr * $ncols + $nc) < $nfiles) echo "<td>" . ($nr * $ncols + $nc) ."</td><td>\n" ; $nf = $nrows * $nc + $nr ; if ( $sf < $nfiles) { echo "<td class=\"sf\"><a href=\"upload.php?file=" . $files[$nf] . '">' . substr($files[$nf], strpos($files[$nf], '/') + 1) ."</a></td><td align=\"right\" class=\"sf\">" . filesize($files[$nf]) . "</td>\n" ; } else echo "<td> </td><td> </td>\n" ; if ( ($nc >= 0 && $nc < $ncols - 1 ) ) echo '<td> </td>' ; } echo "</tr>\n" ; } ?> </table> </div> <div align="center"> <hr /> <h2>- Or -<br />Enter <u>Plain-Text</u> CSV data to upload in the form below:</h2> <?php // show the <textarea> form and get the text get_text($debug) ; // include("../$footer") ; return ; // ================================================== // process_text -- get text from <textarea> form // ================================================== function get_text($debug) { // look for data in $content via POST // save to $filename and edit // // save to $filename if (isset( $_POST['content'] ) ) { $content = trim(stripslashes( $_POST['content'] )) ; $filename = getfilename(substr($content, 0, 2048)) ; if (!$filename) { echo '<h2>error -- no file name found in file -- <a href="upload.php">Go Back</a></h2>' ; return ; } else { $filecsv = "data/$filename.csv" ; // $fp = fopen($filecsv, "w") or die ("<p>Error opening $filecsv in write mode!</p>") ; fwrite( $fp, $content ) ; fclose($fp) or die ("<p>Error closing $filecsv!</p>") ; // echo "<h3 align=\"left\">CSV data saved to \"$filename.csv\"</h3>" ; // // save transaction to admin log writelog($filecsv) ; } } // ?> <form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post"> <table> <tr> <td><textarea rows="25" cols="150" name="content"><?php // if file selected, read it into textarea echo file_get_contents( $_GET['file'] ) ; ?></textarea></td> </tr> <tr> <td align="center"><input type="submit" value="Save CSV Data" /></td> </tr> </table </form> <?php // end of function process_text } ?> Quote Link to comment https://forums.phpfreaks.com/topic/224860-large-post-failure/#findComment-1161455 Share on other sites More sharing options...
PFMaBiSmAd Posted January 18, 2011 Share Posted January 18, 2011 How exactly do you know that part of the file is being cut off? Are you just looking at the file size or are you looking at the saved contents of the file and comparing it with the original? Is there anything unique about the point where the file is being cut off, such as single or double quote characters? Quote Link to comment https://forums.phpfreaks.com/topic/224860-large-post-failure/#findComment-1161467 Share on other sites More sharing options...
tcloud Posted January 18, 2011 Author Share Posted January 18, 2011 I looked at file sizes with ftp -- have not looked to see where in the file it is failing. Remember everything works perfectly on local WAMP server -- i.e. I have already thrashed out CSV problems she was having. I will look at the file to see what's different. (I am trying to make this as simple for her as possible -- don't even want to confuse the issue by her having to browse for the file in a folder to upload it.) thanks Quote Link to comment https://forums.phpfreaks.com/topic/224860-large-post-failure/#findComment-1161472 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.