Wrox Programmer Forums
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 17th, 2005, 12:25 AM
Registered User
 
Join Date: May 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default HTTP downloads

Hi,

I need some help as a newbie.

I'm trying to create a web page that allow file transfer via HTTP. Most searches on Google turns out FTP, a protocol that is blocked by my company server.

Some sites I visited to download freewares offer downloads via HTTP or FTP.

I followed the instructions in the book on Apache, PHP, and MySQL to setup most of the stuff. I'm on WinXP.

Thanks.



Wongster, your friendly Monster
 
Old May 17th, 2005, 05:00 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

So what's the problem? Do you know that you can just provide a hyperlink to any type of file, and if its not HTML, GIF, (or some other file which the browser knows how to display) then the browser will just open a 'Save' dialog and presto you've got the file via HTTP.

Or do you want to somehow stream the file via PHP?

Explain a bit more about what exactly you're trying to accomplish.

rgds
Phil
 
Old May 19th, 2005, 05:36 AM
Registered User
 
Join Date: May 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Phil,

Thanks for your reply.

I created a link to a file to test it out. Served to the page on another machine and click on the link. No respond except the change in color of the link to purple. I thought that happens because the file is on another partition in the server. Moved the file to the documentroot directory. Still no luck.

I tried a number of file types (mp3, doc, pdf etc) without success.

I'm absolutely new to this. Please pardon my ignorance.

Thanks.

Wongster :)

Wongster, your friendly Monster
 
Old May 20th, 2005, 04:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

OK take a step back.

I have IIS running on my PC here. If I create a file called foo.bar in c:\inetpub\wwwroot, then I can put this hyperlink in an HTML file on my PC "<a href="http://localhost/foo.bar">get file</a>" and when I click it I get a dialog box asking if I want to save the file foo.bar

What's different on your setup?
 
Old May 20th, 2005, 12:51 PM
Registered User
 
Join Date: May 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I managed to figure out what went wrong.

I was trying to create a hyperlink from a directory on other partition. I copied a sample pdf over to the document root again. This time, it works. Confirmation was done with a mp3 file. The media player pops out.

I guess the learning curve is little steep at the beginning for someone like me, who is rather new. But I'm determined to learn.

Thanks Phil.

Regards,

Wongster :)

Wongster, your friendly Monster
 
Old June 8th, 2005, 05:01 PM
Registered User
 
Join Date: May 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Here is good example if you want to force a download programmatically. :-)

private void Page_Load(object sender, System.EventArgs e){
 string FileName;
 string FExt;

 FileName = Request["f"];
 FExt = FileName.Substring(FileName.IndexOf(".") + 1);

 if (FileName == ""){
  Response.Write("No file was specified");
  Response.End();
 }

 Response.ContentType = "application/" + FExt;
 Response.AddHeader("content-disposition", "attachment; filename=" + FileName.Substring(FileName.LastIndexOf("\\")));

 string FilePath = FileName;
 Response.WriteFile(FilePath);
 Response.End();
}


Regards



---------------------------------------------------------------------
http://www.AllAmericanJobs.net
Job search from your desktop and automatically sends your resume.
---------------------------------------------------------------------





Similar Threads
Thread Thread Starter Forum Replies Last Post
downloads JimBloomfield BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 2 June 23rd, 2006 09:17 AM
Downloads alexisb BOOK: Expert One-on-One Access Application Development 7 January 1st, 2005 10:24 PM
HTTP Status 405 - HTTP method GET .... nsakic Servlets 1 January 25th, 2004 04:50 PM
C# Downloads Mike Smith Wrox Book Feedback 3 December 14th, 2003 04:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.