Link to home
Start Free TrialLog in
Avatar of ovnadmin
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:
/ftp/user1/
/ftp/user2/
/ftp/user3/
etc

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
</FilesMatch>

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

Thank you for your time.
ASKER CERTIFIED SOLUTION
Avatar of noci
noci

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ovnadmin
ovnadmin

ASKER

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.

Noci,

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.
Hello,

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!