download script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi, i coded some basic file downloader (for word, excel, powerpoint,
pdf, etc files). My question is, do i have to use a special header
before sending the file to the user in the http request? this is the
code:

<?php
$id = $_GET['id'];
if(!is_numeric($id)) {
	header('Location: '.$_SERVER['HTTP_REFERER']);
	die();
}
# Verify that file linked to the ID exists
$sql = 'SELECT * FROM files WHERE id = '.$id;
$rs = &$cnn->Execute($sql);
if (!$rs->EOF) {
	# File exists
	$record = array();
	# Increments download-times count
	$record['downloads'] = $rs->fields['downloads']+1;
	$sql = $cnn->GetUpdateSQL($rs, $record);
	$cnn->Execute($sql);
	header('Location: /files/'.basename($rs->fields['filename']));
	die();
} else {
	# File doesn't exist
	header('Location: '.$_SERVER['HTTP_REFERER']);
	die();
}
?>

As you can see, im only using header to redirect the user to the FILE
itself. Is that ok? or do i have to set some kind of binary header?

Thanks,
Andres



--
Slds,
Andrés Santos, IIG

*****************************
cel: (593) 9 7026627
http://www.egobits.com
*****************************


PHP Data object relational mapping generator
http://www.metastorage.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux