0

I am using jszip to create a zip file using javascript.And I want to zip a folder. I am using the following sample code to create zip file

var zip = new JSZip();
zip.file("Hello.txt", "Hello World\n");
var img = zip.folder("images");
img.file("smile.gif", imgData, {base64: true});
var content = zip.generate();
location.href="data:application/zip;base64,"+content;

Using the above code the download popup is coming. But I want to save that zip file in a particular location without browse. How I can implement that. Thanks in advance for answer

2
  • you want it in javascript , why tag JAVA ?? Commented Jun 7, 2013 at 6:26
  • most of the java people aware of javascript Commented Jun 7, 2013 at 9:22

2 Answers 2

1

Just for the information, zip.generate() has been removed in jsZip 3.0

Sign up to request clarification or add additional context in comments.

Comments

0

You can not save zip or any other file at particular position using javascript or other scripts without browser, it's security violation, so as per my knowledge you can not do that at list by javascript.

4 Comments

Thanks...but my requirement is - in my D:\ drive i have a folder contains two files. i need to zip that folder in the same D:\ location.. is that possible?
@madas : considering it true , as far as i know , that java script cant save files , you can make an ajax call to some server side action and do so , the zipping will be done in server side , but you initiate and control it from javascript ........... just a thought
@HussainAkhtarWahid right, but even you can not do so in server side, flow will be like you can upload that d drive file to server using ajax call server will zip it and return back to client so it will be downloaded to browser, server also can not access client's machine drive...
i wnat to upload 2 or 3 files to server from default client location..i.e. "D:\smad\" . ihave two fiels in that folder . i wnt to upload those two files automatically to the server..i dont have any upload window..is that possible using ajax call

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.