If I was running a website and wanted to make a download link for a .docx file to let users download it what would be the best way? I do not want to zip or rar it, or compress it in any way If i create a normal a href link to the file it will download incorrectly or create problems for some or most users Thanks
What kinds of problems? I can't recall ever seeing an issue with an href link to a source doc, but then again, it's been a while since I tried.
I've never heard of any delivery issues with doc or docx files and I support thousands of people who deliver files. The only thing anyone ever complains about is that they can't open the newer Office 2007 / 2010 docx format because they don't have the compatibility pack update installed.
You have two options, depending on whether you have access to your server config or if you have a server-side script. If you're using php, you can use something like: <?php //define content as a docx header('Content-type: application/docx'); // set the filename header('Content-Disposition: attachment; filename=download.docx'); // set the filesize header('Content-Length: '.filesize("download.docx")); // say where the file is //read the file to be downloaded - path/to/document/file.docx readfile_as_chunks("path/to/document/file.docx"); function readfile_as_chunks($filename){ $chunksize = 1*(1024*1024); // how many bytes per chunk $buffer = ''; $handle = fopen($filename, 'rb'); if ($handle === false) { return false; } while (!feof($handle)) { $buffer = fread($handle, $chunksize); print $buffer; } return fclose($handle); } ?> Code (markup): If you're using a different server-side language you'll need to google for that. If you have access to your server config, e.g. apache, you can do something like: <FilesMatch "\.(?i:docx)$"> ForceType application/octet-stream Header set Content-Disposition attachment </FilesMatch> Code (markup):
nevermind, I was being stupid I forgot the docx is for 2007 only. So the errors were on earlier office versions