hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Downloading File
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

Downloading File

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 09-08-2002, 12:40 AM
CChard CChard is offline
WHT Addict
 
Join Date: Mar 2002
Posts: 123

Downloading File


How do you get PHP to start a download of a file (lets say a .zip)?

Here is my file:

PHP Code:
<?php
include("functions.php");
if (!
db_connect())
{
echo 
"Error: Could not connect to database. Please Contact Admin";
exit;
}
$result mysql_query("select * from files WHERE id='$id' AND status='0'");
$row mysql_fetch_array($result);

if(
mysql_num_rows($result)==0)
{
echo 
"Error: Could not find file in database. Please Contact Admin";
exit;
}

$file stripslashes($row['url']);
$downloads $row['downloads']+1;
$fp fopen($file"r");

if(!
fp)
{
echo 
"Error: Could not download file. Please Contact Admin";
exit;
}
else
{
$query "update files set downloads='".$downloads."' where id='".$id."'";
  
$result mysql_query($query);
echo 
"You may close this window.";
fclose($fp);
exit;
}

?>
The program finds the URL (Ex: http://www.atlanticrail.com/files/ac0001.zip) and then I need it to start a download.

I don't get any errors, just the "You may close this window" message. Meaning it opened the file.

__________________
www.atlanticrail.com

Reply With Quote


Sponsored Links
  #2  
Old 09-08-2002, 12:46 AM
mind21_98 mind21_98 is offline
Web Hosting Master
 
Join Date: Dec 2000
Location: San Diego, CA
Posts: 1,571
You're just in luck:

http://www.webhostingtalk.com/showth...threadid=70867

There should be enough info in that thread to help you.

__________________
-Mooneer
Thoughtbug Software: Hosting shouldn't require any thought.
Legitimate host? Support the Code of Ethical Conduct

Reply With Quote
  #3  
Old 09-08-2002, 12:53 AM
CChard CChard is offline
WHT Addict
 
Join Date: Mar 2002
Posts: 123
I saw that... I didn't find much help there. Thanks, though.

Anyway... in the few minutes, I found another soultion to my problem. So my script works now.

However, if anyone has any other ideas I would like to hear them.

__________________
www.atlanticrail.com

Reply With Quote
Sponsored Links
  #4  
Old 09-09-2002, 11:26 AM
OldOne OldOne is offline
WHT Addict
 
Join Date: Sep 2002
Posts: 167
www.hotscripts.com/PHP/Scripts_and_Programs/ File_Manipulation/Download_Systems/

You can watch at the above link.

Reply With Quote
  #5  
Old 09-09-2002, 06:46 PM
Rich2k Rich2k is offline
Web Hosting Master
 
Join Date: May 2002
Location: UK
Posts: 2,994
That linked thread gives you the PHP code to force a file download (rather than opening it in the browser)

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
ISPs Launch Copyright Alert System to Curb Infringement Web Hosting News 2013-02-27 16:14:36
New Anti-Piracy Law in Japan Prosecutes Downloaders, Could Impact ISPs Web Hosting News 2012-10-02 16:30:30
DEMO VIDEO: Idera Continuous Data Protection (Part 2) Whir Tv 2012-09-25 11:52:56
SingleOS Launches Fuscan Linux Cloud 2.0 Web Hosting News 2011-08-12 19:09:05
Web Host WebHostingBuzz Partners with Cloud Platform SMEStorage Web Hosting News 2011-06-01 18:10:25


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?