Skip to content

Commit c9caa7b

Browse files
committed
create directory if not exists
1 parent 2038a6c commit c9caa7b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Classes/Export.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ public function export($name = null): string
2626
*/
2727
public function csv($users, $name): string
2828
{
29-
$file_name = is_null($name) ? 'users/sas3/users_' . rand() . '.csv' : 'users/sas3/'.$name.'.csv';
29+
$path = public_path('users');
30+
if (!file_exists($path)) {
31+
mkdir($path);
32+
}
33+
$file_name = is_null($name) ? 'users/sas3_users_' . rand() . '.csv' : 'users/'.$name.'.csv';
3034
$columns = array('Username', 'First Name', 'Last Name', 'Expiration', 'Parent', 'Profile', 'Pass');
3135
$file = fopen($file_name, 'w');
3236
fputcsv($file, $columns);

0 commit comments

Comments
 (0)