Current location: Hot Scripts Forums » Programming Languages » PHP » Downloadeing files in php

Downloadeing files in php

 
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-12-09, 10:28 AM
Wanasa Wanasa is offline
Newbie Coder
 
Join Date: Oct 2008
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
Downloadeing files in php

hi there,

am working on download script and i want it to work just like realplayer.com and microsoft where a yellow bar is shown at the top of the browser and download the file in most pupular web browser such as Firefox and IE ...

also i want it to count the number of downloads, Here where is submit and update query. is there an query that update fields by adding anumber to it or do i have to do read the field and then do the math thing and update the field again ...

here are the headeres and the code am working on :
when you click on the download link you will be targted to the page download.php and in IE it shows a box to save or to open as or to cancel in firefox it shows to download the file download.php ( which is a problem ) and the page where you've praccess on download link it will remain as it is no refreashin or anything ...

the download.php code is :
PHP Code:
<?php

# including the configuration files and all needed functions files
require_once("includes/config.php");


# SET THE GOLBALES FOR THE SYSTEM
# ------------------------------------------------------

# the defualt variables for the templates in the system
global $vars;

# the settings from the config.php file
global $setting;

# the language file array
global $lang;

# ------------------------------------------------------

# i need to supbmit thies tow queries too. how can it be done with headers and is it the write way !!
/*
# read the numof downloades and update it
$downloaded = mysql_query("SELECT `downloaded` FROM `files` WHERE `filename` = "'". $_REQUEST['filename'] ."'");
# update the number of downloadeds by one
$update = mysql_query("UPDATE `files` SET `downloaded` = '". (#downloaded + 1) ."' WHERE `filename` = "'". $_REQUEST['filename'] ."'");
*/

$requested_file $_REQUEST['nickname'] . "___" $_REQUEST['filename'];

$download_path getSetting('filesdirectory') . "/";

$size filesize ($download_path $requested_file);



    
header("Content-Type: application/octet-stream");
    
header("Content-Disposition: attachment; filename=" $_REQUEST['filename']);
    
header ('Expires: 0');
    
header ('Last-Modified: ' gmdate ('D, d M Y H:i:s'filemtime ($requested_file)) . ' GMT');
    
header ('Pragma: public');
    
header ('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    
header("Content-Type: application/force-download");
    
header("Content-Type: application/download");
    
header ('Accept-Ranges: bytes');
    
header ('Content-Length: ' $size);
    
header ('Connection: close');

    
readfile($download_path $requested_file); 
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP in text files from lead, how? jeppchen PHP 2 04-22-09 01:24 PM
create files in php banli PHP 3 10-31-08 10:49 PM
Uploading files into server using PHP and MySQL sccc2008 Script Requests 1 01-26-07 03:19 AM
php files with no extension? liljoeyjordison PHP 4 09-03-05 02:46 PM
PHP Runner , Preview PHP files ! moslehi@gmail.com General Advertisements 3 12-08-04 04:01 PM


All times are GMT -5. The time now is 03:39 AM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.