Note that there are some explanatory texts on larger screens.

plurals
  1. PO.csv too many rows to upload?
    primarykey
    data
    text
    <p>I don't really know much PHP. But anyways I am not able to upload a .csv file using the following php. The file is less the 5MB. What's going on? There are a total of 79,500 rows of records with just four columns and simple value like such:</p> <pre><code>27589 16990 161.7000095 0.838494 27589 17067 161.7000095 0.838494 27820 17144 315.7000095 0.859458 27820 17221 315.7000095 0.859458 27820 17606 315.7000095 0.866033 27820 17683 315.7000095 0.866033 </code></pre> <p>I dissected the file and uploaded up to 60,000 rows of data and bombed out, which is 1.93MB. Anything beyond that just doesn't work. The error code is " -- CSV file to load: failure to upload the file &gt;&gt;&gt; Error code: 1<br> " error code 1. </p> <p>Also how do I print a complete PHP error message instead of just the value "1" which I'm not sure what it corresponds to? ie... output print like this "UPLOAD_ERR_INI_SIZE: 1"?</p> <pre><code>&lt;?php // using upload at click from http://code.google.com/p/upload-at-click/ // FileData is the name for the input file $file_result = ""; $file = $_FILES['Filedata']; $allowedExtensions = array("csv", "txt"); $arrayVar = explode(".", $file["name"]); $extension = end($arrayVar); //commented out for “Only variables should be passed by reference” error //$extension = end(explode(".", $file["name"])); function isAllowedExtension($fileName) { global $allowedExtensions; return in_array(end(explode(".", $fileName)), $allowedExtensions); } if($file["error"] &gt; 0){ echo "failure to upload the file &gt;&gt;&gt; ". "Error code: ".$file["error"]."&lt;br&gt;"; }else{ //echo " &gt;&gt;&gt; CURRENT DIR: ".getcwd() . "\n"; $workDir = getcwd(); $dir = substr($workDir, 0, -10); $path = $file["name"]; $newFileLoc = $dir.$path; $file_result.= "&lt;br&gt; Upload: " . $file["name"] . "&lt;br&gt;" . " Type: " . $file["type"] . "&lt;br&gt;" . " Size: " . $file["size"] . "&lt;br&gt;" . " file uploaded to: ".$newFileLoc."&lt;br&gt;"; // txt - text/plain // rtf - application/msword // dat/obj - application/octet-stream // csv - application/vnd.ms-excel // maximum 200 MB file - 200,000,000 k if ( ($file["type"] == "application/vnd.ms-excel" || $file["type"] == "text/plain") &amp;&amp; isAllowedExtension($file["name"]) &amp;&amp; ($file["size"] &lt; 200000000) ) { move_uploaded_file($file["tmp_name"], $newFileLoc); //echo $file_result.=" &gt;&gt;&gt; File uploaded successfull!!"; echo "|".$path;//"filePath : " . $newFileLoc; }else{ echo " &gt;&gt;&gt; NOT a file valid: ". isAllowedExtension($file["name"]); } } </code></pre> <p>?></p> <p>This is the line that was added as suggested by another user to catch the error correctly. Please let me know if that's right sorry i don't know much PHP at all. Anyways, the error printed is just "-- CSV file to load: failure to upload the file &gt;&gt;&gt; Error code: 1<br> "</p> <pre><code>&lt;?php // using upload at click from http://code.google.com/p/upload-at-click/ // FileData is the name for the input file ini_set('display_errors', 1); error_reporting(E_ALL); $file_result = ""; $file = $_FILES['Filedata']; $allowedExtensions = array("csv", "txt"); $arrayVar = explode(".", $file["name"]); $extension = end($arrayVar); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload