Click to See Complete Forum and Search --> : PHP header zip...
Pixel-Artist
06-10-2005, 03:51 AM
I made this...
<?php
$filename = "thiszip.zip";
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="' . $filename . '"');
readfile($filename);
$file = fopen('iplog.txt', 'a', 1);
$ipz = getenv("REMOTE_ADDR");
$text = "$ipz\n";
fwrite($file, $text);
fclose($file);
?>
It works, but after I download it, it says it is currupt. If I download the file normaly it works fine. Whats wrong?
ShrineDesigns
06-10-2005, 02:47 PM
you forgot one thingheader("Content-length: " . filesize($filename));that shoud do the trick
Pixel-Artist
06-10-2005, 04:39 PM
you forgot one thingheader("Content-length: " . filesize($filename));that shoud do the trick
Works, thx.
Sheldon
06-10-2005, 10:54 PM
could it be posable to edit this to write the time and more functions say as if the user filled out a form then was redirected to that page, also chose the file depending on the location?
Some thing like this?
<?php
$filename = $_POST['filename'] ".zip";
$name = $_POST['name'] ".zip";
$time = ;//php function for get time
header('Content-type: application/zip');
header("Content-length: " . filesize($filename));
header('Content-Disposition: attachment; filename="' . $filename . '"');
readfile($filename);
$file = fopen('iplog.txt', 'a', 1);
$ipz = getenv("REMOTE_ADDR");
$text = "$ipz\n$name\n$time\n$filename\n______________\n";
fwrite($file, $text);
fclose($file);
print "$filename was successfully downloaded, Thanks $name";
?>
Thanks Sheldon
Sheldon
06-10-2005, 10:56 PM
or even for the file call it from the referrer address
like http://www.domain.com/downloads.php?file=program
$filename would then be "program"?
Thanks again
Sheldon
Pixel-Artist
06-11-2005, 03:52 AM
could it be posable to edit this to write the time and more functions say as if the user filled out a form then was redirected to that page, also chose the file depending on the location?
Some thing like this?
<?php
$filename = $_POST['filename'] ".zip";
$name = $_POST['name'] ".zip";
$time = ;//php function for get time
header('Content-type: application/zip');
header("Content-length: " . filesize($filename));
header('Content-Disposition: attachment; filename="' . $filename . '"');
readfile($filename);
$file = fopen('iplog.txt', 'a', 1);
$ipz = getenv("REMOTE_ADDR");
$text = "$ipz\n$name\n$time\n$filename\n______________\n";
fwrite($file, $text);
fclose($file);
print "$filename was successfully downloaded, Thanks $name";
?>
Thanks Sheldon
I like the way you think...
Pixel-Artist
06-11-2005, 04:57 AM
The whole $name thing would be good if you had a php member system.
This is what I got...
<?php
$filename = "thiszip.zip";
header('Content-type: application/zip');
header("Content-length: " . filesize($filename));
header('Content-Disposition: attachment; filename="' . $filename . '"');
readfile($filename);
$file = fopen('iplog.txt', 'a', 1);
$ipz = getenv("REMOTE_ADDR");
$date = date("m/d/Y h:i:s A");
$text = "IP: $ipz - Date & Time: $date - File: $filename \n";
fwrite($file, $text);
fclose($file);
?>