עם PHP אפשר, אבל...
שים לב טוב למה אתה עושה, במובן האבטחתי.
<?php $fname = "file.ext" // The file you want to send, witout the path $file = "/path/to/file/" . $file_name // The path to the file if (...) { // Whatever the condition is // Open and read file $fh = fopen($file, "rb"); $c_length = (int) filesize($file); $content = fread($fh, $c_length); fclose($fh); // Send HTTP headers to browser header("Content-type: application/octet-stream; name='$fname'"); header("Content-disposition: inline; filename='$fname'"); header("Content-length: $c_length"); // Send file echo $content; } else { ... // Do whatever you want } ?>
אם זה לא מספיק, יש דיון מעניין באתר של PHP בתיאור של
הפונקציה header