Link to home
Create AccountLog in
Avatar of ovnadmin

asked on

Force FTP File Download in Web Browser (VSFTP)

Hi everyone.

Here's my issue:

I have a CentOS 6.6 VSFTP server here setup using virtual user accounts. When users connect to the FTP server and attempt to download a .txt file, .pdf, or other document, their browser opens it in a new tab instead of downloading/saving it. I'd like to force files open in this FTP server to automatically be downloaded, specifically .txt files.

FTP root directory is /ftp, though virtual users are chrooted in their home directories. Directory structure is:

I've followed about a dozen different links of people posting similar issues, mostly related to creating a .htaccess file in the ftp root directory with the following (or similar) contents; however, I've had no success.
<FilesMatch "\.(?i:doc|odf|pdf|rtf|txt)$">
  Header set Content-Disposition attachment

Is there a solution to this problem that will work with VSFTP?

Thank you for your time.
Avatar of noci

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of ovnadmin


So short version: use web server (best with https access, for security & privacy), and try to force a binary mime-tag on a transfer and avoid IE on the client side.


Unfortunately, we cannot use a web server for this application as this FTP server is integrated with our product line and used by those products in the field. In this particular case, I need users at a remote location to have access to a single text file. FTP and works well with the added step of right clicking the link and selecting "save link as" on the document that's needed. I'm just trying to simplify the download process a bit.
If it is about downloading - really go with http... Your customers will become 8,3% happier.
sorry the ftp server cannot influence the browser to have a different view on the downloaded file.
Changing the extension to .bin might help, in that case the users need to rename the file locally.

Unfortunately, we were not able to force file downloads via FTP in the web browser, so, as you suggested, we rebuilt this solution as a web server and used apache to host the files that were needed.  

Thanks again for your advice!