Write binary data to file in javascript (like image file)

Is there a way to write binary data to local disk files in javascript like image files?

I try it but it works only for txt files:

                                    var fp = fopen('image.jpg', 3);
                                    fwrite(fp, '<?php echo $contents; ?>')

Thanks in advance
Who is Participating?
Gurvinder Pal SinghCommented:
In short, you cannot save a file using javascript on client side.

You need to invoke server-side script to save this on server side.
ZumbaJrAuthor Commented:
I've requested that this question be deleted for the following reason:

It's wrong
Gurvinder Pal SinghCommented:
Kindly explain the reason in detail, or I will have to object to your request.
Gurvinder Pal SinghCommented:
saying "its wrong" and closing the question is not right. Please explain why are you closing the answer
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.