This function is used to add a file into a ZIP file created with zip_create.
If the call is successful, the function will return 0, otherwise it will throw a fatal error.
The src file is only loaded when zip_save is called later, so an invalid file will not throw an error during this call.
NOTE This functionality is not available for the HTML5 target platform.
zip_add_file(zip_object, dest, src);
Argument | Type | Description |
---|---|---|
zip_object | ZIP File | A ZIP file created with zip_create |
dest | String | The destination file name to be created in the ZIP. Can include directories. |
src | String | The source file to be placed into the ZIP |
var _zip = zip_create();
zip_add_file(_zip, "new.txt", "new.txt");
zip_add_file(_zip, "sounds/snd_attack_arc_01.wav", "snd_attack_arc_01.wav");
zip_save(_zip, "upload.zip");
This creates a new ZIP file, adds two files to it (with the second file in a subdirectory called sounds/) and then saves the ZIP to disk as upload.zip.