Closed tech4him1 closed 7 years ago
Related StackOverflow answer (from CWSpear):
When you put a file in the archive, you can't have absolute files (files starting with a slash) or else it won't open in Windows for some reason.
So got it working not because he (Jesse Bunch, the selected answer at the time of this writing) removed the containing folder but because he removed the starting slash.
I fixed the issue by changing
$zip->addFile($file, $file); // $file is something like /path/to/file.png to
// we make file relative by removing beginning slash so it will open in Windows $zip->addFile($file, ltrim($file, '/')); and then it was able to open in Windows! http://stackoverflow.com/a/11350197
So we should just be able to remove the beginning slash from $local_path
for the filename in the zip file. I can test it on Windows and Ubuntu if you want.
Done! Please download the new source and test it!
Works on Windows 10
In 7-zip, the path shows up as
hugo-export.zip//hugo-export/...
. There is an extra no-name directory as the root directory.