Hello, i have a PHP script that will pop up a save as dialog box. This script works well at Firefox and IE7, but when i test it with Safari for Windows. It will download the PHP script itself and not the file that i want to give to user. Can someone help me, pls? I really need this. Thanks in advance.... <?php include("database_setup.php"); $getType = $_POST['photo_type']; $getName = $_POST['photo_name']; $getEmail = $_POST['textfield']; $user = $_SESSION["username"]; if(strcmp($getType, "home") == 0) { $file = "Homepage_Photo"; if(copy("./homepage_photo/" . $getName, "./encrypted_files/".$getName)) { $location = "./encrypted_files/" . $getName; } } else if(strcmp($getType, "watermark") == 0) { $file = "Watermarked_Photo"; if(copy("./watermarked_photo/" . $getName, "./encrypted_files/".$getName)) { $location = "./encrypted_files/" . $getName; } } if(strcmp($getEmail, $user) != 0) { $_SESSION["downloadMsg"] = "Sorry, username that you input : $getEmail, is not a valid user"; header("Location: ./photo.php"); } else { $gabung = "encrypt " . $location . " " . $getEmail; $aes = `java AESfile $gabung`; if(strcmp(trim($aes), "Encryption Success") == 0) { @unlink($location) or die("Cannot delete file"); $onlyName = substr($getName, 0, strlen($getName) - 4); $fileName = $onlyName . ".uow"; $fileLoc = "./encrypted_files/" . $fileName; header("Content-disposition: attachment; filename=".$fileName); header("Content-type: application/octet-stream"); header("Pragma: no-cache"); header("Expires: 0"); $fp = fopen("$fileLoc","r"); $str = fread($fp, filesize($fileLoc)); echo $str; fclose($fp); } } ?> Code (markup):
Well, i got an answer from other forums I changed my code to readfile($fileLoc), and now Safari can download the file. But when i want to download a jpg image, Safari will automatically open the file @ browser. I want user to download the image. Can someone help me, pls? Thx