-
-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the output method can not be used for saving CSV document to the underlying filesystem #434
Comments
@mitmelon thanks for using the library. As explain by the exception message your
|
Which means the library does not support locations with path like file/filename.csv because have tried this too and does not work... It can only save files to current directory. And again it will be good if the library can just write directly inside a file and save the file inside the desired destinations... Instead of forcing it to store files in same director... As the directory might be public and people could access the file... |
No as a matter a fact, I believe you are using the wrong method for your use case. Again if you refer to examples in the documentation You will see that:
So in your example you should do the following instead: <?php
use League\Csv\Writer;
$csv = Writer::createFromPath(__DIR__.'/../users.csv');
$csv->insertOne($header);
$csv->insertAll($records); The Hopes this clarify your behaviour better. |
Thank you very much... I was using createFromString(); that's where the issue was... Thanks for the clearifications... |
When using
$csv = Writer::createFromString();
$csv->insertOne($records);
$csv->output(DIR.'/../users.csv');
Error popups below... Why cant it support path?
Fri Aug 13 15:59:01.224064 2021] [php:error] [pid 4580:tid 1716] [client 127.0.0.1:52529] PHP Fatal error: Uncaught League\Csv\InvalidArgument: The filename
C:\\xampp\\htdocs\\project\\src\\Register/../users.csv
cannot contain the "/" and "\" characters. in vendor\league\csv\src\InvalidArgument.php:40\nStack trace:\n#0 vendor\league\csv\src\AbstractCsv.php(392): League\Csv\InvalidArgument::dueToInvalidHeaderFilename('C:\\xampp\\htdocs...')\n#1 vendor\league\csv\src\AbstractCsv.php(367): League\Csv\AbstractCsv->sendHeaders('C:\\xampp\\htdocs...')\n#2The text was updated successfully, but these errors were encountered: