what's wrong with this code? it works fine except when i download the file there's nothing in the file and i've tried removing the unlink.

$F = fopen("filename","w");
fwrite($F,"blah");
fclose($F);
header('Content-Disposition: attachment; filename=title');
unlink("filename");

Recommended Answers

All 3 Replies

First of all, you dont have an extension to the file. secondly, you aren't writing anything to the file.
Eg.

<?php
header('Content-Disposition: attachment; filename=filename.txt');
echo "blah blah";
?>

First of all, you dont have an extension to the file. secondly, you aren't writing anything to the file.
Eg.

<?php
header('Content-Disposition: attachment; filename=filename.txt');
echo "blah blah";
?>

i do have an extesion i was just putting random stuff in there i had stuff like blah.html or blah.txt. Also i did write something to the file because when i remove the unlink part and go to the file that i just created there's contents in the file.

So ? what is the problem ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.