Saving a file in PHP?







I have a PHP script that spiders cbssports.com for their football player information and returns it to the screen in a CSV format. I can save this info to a file no problem, but is there a way that upon loading the .php file, the user is automatically prompted to save that file to their computer?


Answer
<?php require_once( "phpscriptname.php"); ?>

<html>
<head>
<script language="javascript" type="text/javascript">
window.location = "http://www.website.com/file.CSV";
</script>
</head>
</html>



Throw into a .php file, change the require name up top of your data extracting script, change the URL path to the file. When the script finishes runtime it will continue to the page and relocate the user to the file where it will either open it in the browser or ask them to download the file. It depends on how they configure their browser.


Words of Wisdom,
- Hex



P.S.
In regards to the force_download() function..... no...

<?php
$file = "myfile.csv";

if( !file_exists($file) ) die("File not found");

// force the file download
header("Content-Disposition: attachment; filename=\"" . basename($file) . "\"");
header("Content-Length: " . filesize($file));
header("Content-Type: application/octet-stream;");
readfile($file);
?>

This is the proper way to force a download using PHP.

computer virus scam?

Q. i downloaded some program called dr.antispy, suposably a free virus cleaner or something....i cheked how many viruses i had and it turns out i had over 142???, i cheked w/ the one that came w/ my computer and it said i had like 3 so i think dr.antispy is trieng to trick me into buying the complete product, and might have added some spyware, im pretty sure cuz i wont even be on the computer yet i get random porn pop ups. i cant have that happen and iv already tried deleting it, but i cant find it on controll panel. i think it might be under some weird name like .zzjdiskoem, or something, so its really hard for me to delete it if i can't find it....plz help w/ any info. thanx


Answer
Your computer has a Smitfraud infection.

The standard tool to remove this pest is SmitfraudFix. The full removal procedure and the free removal tool is here:
http://siri.urz.free.fr/Fix/SmitfraudFix_En.php

Almost all "general purpose","all-in one" spyware and virus removal programs such as AVG, Norton, or Spybot S & D cannot remove it.

Good luck.




Powered by Yahoo! Answers

Comments :

0 komentar to “Saving a file in PHP?”
 

Sexy Lace Bikini

Leave little to the imagination in this super sexy booty short bikini transparent lace. Adjustable triangle top with peek-a-boo slits ties at neck and back. Matching ruffled booty shorts leave so little to the imagination! 90% Nylon 10% Spandex. Four way stretch means one size fits most. Unlined. Club Wear by Body Zone Read More

LG Scarlet

This event, which was attended by more than 200 media from Middle East and Africa, followed earlier events in Los Angeles and in London that drew celebrities for a mock premiere event to reveal the secret of “Scarlet, The Hit New TV Series,” which had been promoted through broadcast and online trailers.