0

I have a php page running on an apache server and a ftp server that stores the files, on a different machine. The ftp server is not accessible from outside.

I would like that when the user clicks a button on my webpage, the php server connects to the ftp server, retrieves a file, and displays a save as dialog, so that the user can store it.

Any help is appreciated, Radu

3
  • We need code. However, on PHP's manpage for readfile there is a nice little download script. Commented Aug 12, 2012 at 11:26
  • Have you already had a look at PHP’s FTP functions? Commented Aug 12, 2012 at 11:26
  • What code would you need? I only called the ftp in order to retrieve the file, but I do not know how to open the save file dialog without saving the file locally. Commented Aug 12, 2012 at 11:28

1 Answer 1

1

Here you Go.. in download.php write this

$file = 'location/of/your/file.ext';
readfile($file);
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=".$file);
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: binary");

This should work :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.