Outputting Files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Ralle
Forum Commoner
Posts: 38
Joined: Mon Oct 17, 2005 5:05 am

Outputting Files

Post by Ralle »

Read Last post
Last edited by Ralle on Sun Oct 30, 2005 4:13 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

images are sent via a separate stream from the HTML. You need a separate script that pulls the image and resizes it.. I'd suggest storing the resized image because the resampling process is computationally heavy and takes a while. Your page serving rate will severly drop if you don't..
Ralle
Forum Commoner
Posts: 38
Joined: Mon Oct 17, 2005 5:05 am

Post by Ralle »

okay
let's say I have an image uploading script. How would I do to resize it, and store it.. I searched php.net but couldn't find anything
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the second argument to imagejpeg() is the filename to save the image as.
Ralle
Forum Commoner
Posts: 38
Joined: Mon Oct 17, 2005 5:05 am

Post by Ralle »

OK now I need some download script. I have been trying to find a working script for so long. I just need a small script that handles a file to download. could be like: download($filename) very simple :)
I want it o hide the filepath
Ralle
Forum Commoner
Posts: 38
Joined: Mon Oct 17, 2005 5:05 am

Post by Ralle »

this is my script so far:

Code: Select all

<?
// standard hack prevent 
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

$id = $_GET['id'];
$result = mysql_query("SELECT * FROM maps WHERE maps_id='$id'");
while ($row = mysql_fetch_array($result))

$filename = 'maps/' . $row['maps_file'];

$file = fopen($filename, 'r'); 

//set some HTTP headers 
Header('Content-Type: application/x-octet-stream'); 
Header('Content-Transfer-Encoding: binary'); 
Header('Content-Length: ' . filesize($filename)); 
Header('Cache-Control: no-cache, must-revalidate'); //HTTP 1.1 
Header('Cache-Control: post-check=0, pre-check=0', false); //HTTP 1.1 
Header('Pragma: no-cache'); //HTTP 1.0 
Header('Content-Description: Whatever the file is'); 
Header('Content-Disposition: attachment; filename="'.$filename.'"'); 
Header('Title: ' .$filename()); 

while(!$feof($file)) 
     print(fread($file, 4096)); 

fclose($file); 

?>
it outputs:
Fatal error: Call to undefined function: maps/(6)dragonfire.w3m() in /home/hivework/public_html/forum/downloadmap.php on line 25
Post Reply