views:

83

answers:

1

hey i want to make a thing but i need some help.

ive got an index.php with codes. and i added "file" parameter to index.php. so i mean if "index.php?file=/folder/folder/picture.png" is set, go to file. if "file=" not set do not do anything.

I get "file" parameter with $_REQUEST thingy. please help thanks..

+3  A: 

Your question is a bit unclear, but something like this should be what you're looking for:

if(isset($_GET['file'])) {
    header('Content-disposition: attachment');
    header('Content-type: image/png');
    readfile($_GET['file']);
    exit();
}

That would "redirect to file" if the file parameter is set.

Note that this poses a HUGE security hole as users can download any file from your server, but this should give you some pointers at least.

Tatu Ulmanen