When sending the file to the user the user gets Resource ID#2.
When I change the filename to be a non random name... it downloads just fine.
I am 99% certian that it has something to do with the random filename.
anyone know a solution for me?
Code: Select all
//Many people may use this at one time so make random file names
//so files are not overwriten and or errors are not made
srand ((double) microtime( )*1000000);
$ranum1 = rand(0,10);
srand ((double) microtime( )*1000000);
$ranum2 = rand(0,10);
$ind = mt_rand(0, 25);
$alphabet = 'abcdefghijklmnopqrstuvwxyz';
$letter = $alphabetї$ind];
$filename = "serverbat$ranum1$letter$ranum2.bat";
//Create the bat file and open it for writing to...
$serverbat = fopen("$filename", "x+");
//write my contents
fwrite($serverbat, $content1);
fwrite($serverbat, $content2);
//close the bad boy up
fclose($serverbat);
//send the file
$size = filesize($serverbat);
header ("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=$serverbat");
header("Content-Length: $size");header("Content-Disposition: attachment; filename=\"$serverbat\"");
- Thanks for who ever helps me out on this one
Nirus