Welcome Guest, Not a member yet? Register   Sign In
Convert a single column of values into a comma seperated list
#11

[eluser]johnwbaxter[/eluser]
Errors!

A PHP Error was encountered

Severity: Warning

Message: file(/Applications/MAMP/tmp/php/phptbY3qH) [function.file]: failed to open stream: No such file or directory

Filename: controllers/start.php

Line Number: 94
A PHP Error was encountered

Severity: Warning

Message: implode() [function.implode]: Invalid arguments passed

Filename: controllers/start.php

Line Number: 95

bool(false)
#12

[eluser]xwero[/eluser]
so you need the full path to the temp file in php 5.2 you can get it using the sys_get_temp_dir function, if you have an older version you can use this user submitted function
Code:
if ( !function_exists('sys_get_temp_dir')) {
  function sys_get_temp_dir() {
    if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); }
    if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); }
    if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); }
    $tempfile=tempnam(uniqid(rand(),TRUE),'');
    if (file_exists($tempfile)) {
    unlink($tempfile);
    return realpath(dirname($tempfile));
    }
  }
}
#13

[eluser]johnwbaxter[/eluser]
@xwero

I believe i have solved the problem. I borrowed a bit of code from the comments on fgetcsv on php.net and we now have:
Code:
$temp_csv = $_FILES['userfile']['tmp_name'];
                $content = file_get_contents($temp_csv);
                unlink($temp_csv);

                $ret = ereg_replace(chr(13) . chr(10),",",$content);
                $ret = ereg_replace(chr(13),",",$ret);
                //$str = explode("\n", $ret);
            
                echo $ret;

Which works on windoze and mac.

Thanks for all your help today, you've been great.




Theme © iAndrew 2016 - Forum software by © MyBB