Jump to content

Form for Downloading Files


OtagoHarbour
 Share

Recommended Posts

Sorry if this question is really basic and has been answered several times. I was not able to find the answer.The following form can be used to upload a file.<form action="upload_file.php" method="post"enctype="multipart/form-data"><label for="file">Filename:</label><input type="file" name="file" id="file" /><br /><input type="submit" name="submit" value="Submit" /></form>But when I try to use it to select the name of the file to download to I get a message that the file is not found. It's not found because it is to be the name of the save-as file on the user's system.How can I modify the form so that it selects the client system save-as name?Thanks very much,Peter.

Link to comment
Share on other sites

If you want to download a file, just link to it. The download dialog should appear automatically.Certain file types display in the browser. for these ones you should be able to alter the Content-Disposition header using .htaccess or link to a PHP that fetches the content instead.Forms don't download files.

Link to comment
Share on other sites

If you want to download a file, just link to it. The download dialog should appear automatically.Certain file types display in the browser. for these ones you should be able to alter the Content-Disposition header using .htaccess or link to a PHP that fetches the content instead.Forms don't download files.
I don't want to download a file. I want the client user to be able to download a file from my site. The user selects a name from a drop down list of names and then my software determines which file to save on the user's disk. I want the client user to be able to select the name and location to which it should be saved on his or her disk. IOW I want the download dialog to appear on the cleints computer once (s)he has selected the name from the drop down menu.Thanks,Peter.
Link to comment
Share on other sites

The browser automatically displays a dialog asking where to download the file, unless they have changed their browser settings to always download files to the same place. You can't override browser settings.

Link to comment
Share on other sites

The browser automatically displays a dialog asking where to download the file, unless they have changed their browser settings to always download files to the same place. You can't override browser settings.
I guess that makes sense. Would I just initiate a download from the server end and would the user's system put up a save as dialog as a result?Thanks again,Peter.
Link to comment
Share on other sites

Example 1 here shows a very complete technique in PHP. If you don't send some of these headers, bad things will happen. The worst is that the browser will simply display binary data in the browser window.

Edited by Deirdre's Dad
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...