0

I have this fragment:

if(!$wp_filesystem->put_contents( $file_path, $file_content, FS_CHMOD_FILE )) {
    echo 'error during creating the file';
}

This code works properly, but instead of saving the file on the server I would like to display browser dialog box to save the file with this content on local disk.

Thanks in advance for any help.

1 Answer 1

0

... instead of saving the file on the server I would like to display browser dialog box to save the file with this content on local disk

The answer is that that is not what the Filesystem API does. You are trying to, or hoping to, use it incorrectly. It doesn't work that way. The Filesystem API saves to the server filesystem, not to the client disk. The server does not have that kind of control over the browser or the client machine, and for good reason.

What you will need to do is "ask" the browser to download-- something like this: https://stackoverflow.com/questions/8800714/how-to-show-the-save-dialog-using-html

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.