Jump to content
Sign in to follow this  
MimmiNor

PHP 7 fputcsv() Function not creating file

Recommended Posts

I'm trying to understand fputcsv, but I can not

I've pasted the code here: https://www.w3schools.com/php7/func_filesystem_fputcsv.asp

into a file an uploaded it here: https://askerspeiderne.no/lastned.php

But nothing happens when I reload the page. I thought it would create and download a CSV.

What is wrong? The code, the browser, the server?

fputcsv
 <?php
$list = array (
  array("Peter", "Griffin" ,"Oslo", "Norway"),
  array("Glenn", "Quagmire", "Oslo", "Norway")
);

$file = fopen("contacts.csv","w");

foreach ($list as $line) {
  fputcsv($file, $line);
}

fclose($file);
?> 

Please help me!

 

Share this post


Link to post
Share on other sites

It doesn't send the file to the browser, it just saves it in the same directory as that  PHP file.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...